2026-02-06 08:34:15 -08:00
# REST API
2022-11-29 12:49:23 -08:00
2025-02-10 08:43:07 -08:00
Paperless-ngx now ships with a fully-documented REST API and a browsable
web interface to explore it. The API browsable interface is available at
`/api/schema/view/` .
2022-11-29 12:49:23 -08:00
2025-02-10 08:43:07 -08:00
Further documentation is provided here for some endpoints and features.
2023-10-14 16:24:13 -07:00
2022-11-29 12:49:23 -08:00
## Authorization
2026-01-26 09:29:36 +01:00
The REST api provides five different forms of authentication.
2022-11-29 12:49:23 -08:00
1. Basic authentication
Authorize by providing a HTTP header in the form
```
Authorization: Basic <credentials>
` ``
where ` credentials` is a base64-encoded string of
` <username>:<password>`
2. Session authentication
When you're logged into paperless in your browser, you're
automatically logged into the API as well and don't need to provide
any authorization headers.
3. Token authentication
2023-12-02 08:26:42 -08:00
You can create (or re-create) an API token by opening the "My Profile"
link in the user dropdown found in the web UI and clicking the circular
arrow button.
2022-11-29 12:49:23 -08:00
Paperless also offers an endpoint to acquire authentication tokens.
POST a username and password as a form or json string to
` /api/token/` and paperless will respond with a token, if the login
data is correct. This token can be used to authenticate other
requests with the following HTTP header:
` ``
Authorization: Token <token>
` ``
2023-12-02 08:26:42 -08:00
Tokens can also be managed in the Django admin.
2022-11-29 12:49:23 -08:00
2024-02-01 11:46:26 -08:00
4. Remote User authentication
If enabled (see
[configuration](configuration.md#PAPERLESS_ENABLE_HTTP_REMOTE_USER_API)),
you can authenticate against the API using Remote User auth.
2026-01-26 09:29:36 +01:00
5. Headless OIDC via [` django-allauth`](https://codeberg.org/allauth/django-allauth)
` django-allauth` exposes API endpoints under ` api/auth/` which enable tools
like third-party apps to authenticate with social accounts that are
configured. See
[here](advanced_usage.md#openid-connect-and-social-authentication) for more
information on social accounts.
2022-11-29 12:49:23 -08:00
## Searching for documents
2026-04-03 13:53:45 -07:00
Full text searching is available on the ` /api/documents/` endpoint. The
following query parameters cause the API to return Tantivy-backed search
2022-11-29 12:49:23 -08:00
results:
2026-04-03 13:53:45 -07:00
- ` /api/documents/?text=your%20search%20query`: Search title and content
using simple substring-style search.
- ` /api/documents/?title_search=your%20search%20query`: Search title only
using simple substring-style search.
2026-03-12 16:29:57 +00:00
- ` /api/documents/?query=your%20search%20query`: Search for a document
using a full text query. For details on the syntax, see [Basic Usage - Searching](usage.md#basic-usage_searching).
- ` /api/documents/?more_like_id=1234`: Search for documents similar to
the document with id 1234.
2022-11-29 12:49:23 -08:00
Pagination works exactly the same as it does for normal requests on this
endpoint.
Furthermore, each returned document has an additional ` __search_hit__`
attribute with various information about the search results:
` ``
{
"count": 31,
"next": "http://localhost:8000/api/documents/?page=2&query=test",
"previous": null,
"results": [
...
{
"id": 123,
"title": "title",
"content": "content",
...
"__search_hit__": {
"score": 0.343,
"highlights": "text <span class="match">Test</span> text",
"rank": 23
}
},
...
]
}
` ``
2026-03-12 16:29:57 +00:00
- ` score` is an indication how well this document matches the query
relative to the other search results.
- ` highlights` is an excerpt from the document content and highlights
the search terms with ` <span>` tags as shown above.
- ` rank` is the index of the search results. The first result will
have rank 0.
2022-11-29 12:49:23 -08:00
2024-09-23 11:28:31 -07:00
### Filtering by custom fields
You can filter documents by their custom field values by specifying the
2024-10-02 17:15:42 -07:00
` custom_field_query` query parameter. Here are some recipes for common
2024-09-23 11:28:31 -07:00
use cases:
1. Documents with a custom field "due" (date) between Aug 1, 2024 and
Sept 1, 2024 (inclusive):
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["due", "range", ["2024-08-01", "2024-09-01"]]`
2024-09-23 11:28:31 -07:00
2. Documents with a custom field "customer" (text) that equals "bob"
(case sensitive):
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["customer", "exact", "bob"]`
2024-09-23 11:28:31 -07:00
3. Documents with a custom field "answered" (boolean) set to ` true`:
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["answered", "exact", true]`
2024-09-23 11:28:31 -07:00
4. Documents with a custom field "favorite animal" (select) set to either
"cat" or "dog":
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["favorite animal", "in", ["cat", "dog"]]`
2024-09-23 11:28:31 -07:00
5. Documents with a custom field "address" (text) that is empty:
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["OR", [["address", "isnull", true], ["address", "exact", ""]]]`
2024-09-23 11:28:31 -07:00
6. Documents that don't have a field called "foo":
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["foo", "exists", false]`
2024-09-23 11:28:31 -07:00
7. Documents that have document links "references" to both document 3 and 7:
2026-03-12 16:29:57 +00:00
` ?custom_field_query=["references", "contains", [3, 7]]`
2024-09-23 11:28:31 -07:00
All field types support basic operations including ` exact`, ` in`, ` isnull`,
and ` exists`. String, URL, and monetary fields support case-insensitive
substring matching operations including ` icontains`, ` istartswith`, and
` iendswith`. Integer, float, and date fields support arithmetic comparisons
including ` gt` (>), ` gte` (>=), ` lt` (<), ` lte` (<=), and ` range`.
Lastly, document link fields support a ` contains` operator that behaves
like a "is superset of" check.
2022-11-29 12:49:23 -08:00
### ` /api/search/autocomplete/`
Get auto completions for a partial search term.
Query parameters:
2026-03-12 16:29:57 +00:00
- ` term`: The incomplete term.
- ` limit`: Amount of results. Defaults to 10.
2022-11-29 12:49:23 -08:00
2026-04-02 12:38:22 -07:00
Results are ordered by how many of the user's visible documents contain
each matching word. The first result is the word that appears in the most documents.
2022-11-29 12:49:23 -08:00
` ``json
["term1", "term3", "term6", "term4"]
` ``
2022-12-02 19:34:43 -08:00
## POSTing documents {#file-uploads}
2022-11-29 12:49:23 -08:00
The API provides a special endpoint for file uploads:
` /api/documents/post_document/`
POST a multipart form to this endpoint, where the form field ` document`
contains the document that you want to upload to paperless. The filename
is sanitized and then used to store the document in a temporary
directory, and the consumer will be instructed to consume the document
from there.
The endpoint supports the following optional form fields:
2026-03-12 16:29:57 +00:00
- ` title`: Specify a title that the consumer should use for the
document.
- ` created`: Specify a DateTime where the document was created (e.g.
"2016-04-19" or "2016-04-19 06:15:00+02:00").
- ` correspondent`: Specify the ID of a correspondent that the consumer
should use for the document.
- ` document_type`: Similar to correspondent.
- ` storage_path`: Similar to correspondent.
- ` tags`: Similar to correspondent. Specify this multiple times to
have multiple tags added to the document.
- ` archive_serial_number`: An optional archive serial number to set.
- ` custom_fields`: Either an array of custom field ids to assign (with an empty
value) to the document or an object mapping field id -> value.
2023-02-19 16:38:34 -08:00
The endpoint will immediately return HTTP 200 if the document consumption
process was started successfully, with the UUID of the consumption task
2023-04-10 09:38:14 -07:00
as the data. No additional status information about the consumption process
itself is available immediately, since that happens in a different process.
However, querying the tasks endpoint with the returned UUID e.g.
` /api/tasks/?task_id={uuid}` will provide information on the state of the
consumption including the ID of a created document if consumption succeeded.
2022-11-29 12:49:23 -08:00
2026-02-26 08:46:54 -08:00
## Document Versions
Document versions are file-level versions linked to one root document.
2026-03-12 16:29:57 +00:00
- Root document metadata (title, tags, correspondent, document type, storage path, custom fields, permissions) remains shared.
- Version-specific file data (file, mime type, checksums, archive info, extracted text content) belongs to the selected/latest version.
2026-02-26 08:46:54 -08:00
Version-aware endpoints:
2026-03-12 16:29:57 +00:00
- ` GET /api/documents/{id}/`: returns root document data; ` content` resolves to latest version content by default. Use ` ?version={version_id}` to resolve content for a specific version.
- ` PATCH /api/documents/{id}/`: content updates target the selected version (` ?version={version_id}`) or latest version by default; non-content metadata updates target the root document.
- ` GET /api/documents/{id}/download/`, ` GET /api/documents/{id}/preview/`, ` GET /api/documents/{id}/thumb/`, ` GET /api/documents/{id}/metadata/`: accept ` ?version={version_id}`.
- ` POST /api/documents/{id}/update_version/`: uploads a new version using multipart form field ` document` and optional ` version_label`.
2026-06-18 16:20:31 -07:00
- ` PATCH /api/documents/{id}/versions/{version_id}/`: updates the ` version_label` of a specific version.
2026-03-12 16:29:57 +00:00
- ` DELETE /api/documents/{root_id}/versions/{version_id}/`: deletes a non-root version.
2026-02-26 08:46:54 -08:00
2023-05-18 00:59:05 -07:00
## Permissions
All objects (documents, tags, etc.) allow setting object-level permissions
2023-10-13 09:16:17 -07:00
with optional ` owner` and / or a ` set_permissions` parameters which are of
the form:
2023-05-18 00:59:05 -07:00
` ``
2023-10-13 09:16:17 -07:00
"owner": ...,
"set_permissions": {
"view": {
"users": [...],
"groups": [...],
},
"change": {
"users": [...],
"groups": [...],
},
2023-05-18 00:59:05 -07:00
}
` ``
2023-06-26 09:56:56 -07:00
!!! note
Arrays should contain user or group ID numbers.
2023-10-13 09:16:17 -07:00
If these parameters are supplied the object's permissions will be overwritten,
2023-05-18 00:59:05 -07:00
assuming the authenticated user has permission to do so (the user must be
the object owner or a superuser).
2023-06-26 09:56:56 -07:00
### Retrieving full permissions
By default, the API will return a truncated version of object-level
permissions, returning ` user_can_change` indicating whether the current user
2023-06-26 10:08:21 -07:00
can edit the object (either because they are the object owner or have permissions
granted). You can pass the parameter ` full_perms=true` to API calls to view the
full permissions of objects in a format that mirrors the ` set_permissions`
parameter above.
2023-06-26 09:56:56 -07:00
2024-02-01 11:56:57 -08:00
## Bulk Editing
The API supports various bulk-editing operations which are executed asynchronously.
### Documents
2024-03-10 00:11:09 +01:00
For bulk operations on documents, use the endpoint ` /api/documents/bulk_edit/` which accepts
2024-02-01 11:56:57 -08:00
a json payload of the format:
` ``json
{
"documents": [LIST_OF_DOCUMENT_IDS],
"method": METHOD, // see below
"parameters": args // see below
}
` ``
The following methods are supported:
2026-03-12 16:29:57 +00:00
- ` set_correspondent`
- Requires ` parameters`: ` { "correspondent": CORRESPONDENT_ID }`
- ` set_document_type`
- Requires ` parameters`: ` { "document_type": DOCUMENT_TYPE_ID }`
- ` set_storage_path`
- Requires ` parameters`: ` { "storage_path": STORAGE_PATH_ID }`
- ` add_tag`
- Requires ` parameters`: ` { "tag": TAG_ID }`
- ` remove_tag`
- Requires ` parameters`: ` { "tag": TAG_ID }`
- ` modify_tags`
- Requires ` parameters`: ` { "add_tags": [LIST_OF_TAG_IDS] }` and ` { "remove_tags": [LIST_OF_TAG_IDS] }`
- ` delete`
- No ` parameters` required
- ` reprocess`
- No ` parameters` required
- ` set_permissions`
- Requires ` parameters`:
- ` "set_permissions": PERMISSIONS_OBJ` (see format [above](#permissions)) and / or
- ` "owner": OWNER_ID or null`
- ` "merge": true or false` (defaults to false)
- The ` merge` flag determines if the supplied permissions will overwrite all existing permissions (including
removing them) or be merged with existing permissions.
- ` modify_custom_fields`
- Requires ` parameters`:
- ` "add_custom_fields": { CUSTOM_FIELD_ID: VALUE }`: JSON object consisting of custom field id:value pairs to add to the document, can also be a list of custom field IDs
to add with empty values.
- ` "remove_custom_fields": [CUSTOM_FIELD_ID]`: custom field ids to remove from the document.
2024-02-01 11:56:57 -08:00
2026-03-10 11:55:36 -07:00
#### Document-editing operations
Beginning with version 10+, the API supports individual endpoints for document-editing operations (` merge`, ` rotate`, ` edit_pdf`, etc), thus their documentation can be found in the API spec / viewer. Legacy document-editing methods via ` /api/documents/bulk_edit/` are still supported for compatibility, are deprecated and clients should migrate to the individual endpoints before they are removed in a future version.
2024-02-01 11:56:57 -08:00
### Objects
2024-02-08 10:13:15 -08:00
Bulk editing for objects (tags, document types etc.) currently supports set permissions or delete
operations, using the endpoint: ` /api/bulk_edit_objects/`, which requires a json payload of the format:
2024-02-01 11:56:57 -08:00
` ``json
{
"objects": [LIST_OF_OBJECT_IDS],
2024-02-08 10:13:15 -08:00
"object_type": "tags", "correspondents", "document_types" or "storage_paths",
"operation": "set_permissions" or "delete",
"owner": OWNER_ID, // optional
2024-02-01 11:56:57 -08:00
"permissions": { "view": { "users": [] ... }, "change": { ... } }, // (see 'set_permissions' format above)
"merge": true / false // defaults to false, see above
}
` ``
2022-11-29 12:49:23 -08:00
## API Versioning
2026-03-09 15:36:22 -07:00
The REST API is versioned.
2022-11-29 12:49:23 -08:00
2026-03-12 16:29:57 +00:00
- Versioning ensures that changes to the API don't break older
clients.
- Clients specify the specific version of the API they wish to use
with every request and Paperless will handle the request using the
specified API version.
- Even if the underlying data model changes, supported older API
versions continue to serve compatible data.
- If no version is specified, Paperless serves the configured default
API version (currently ` 10`).
- Supported API versions are currently ` 9` and ` 10`.
2022-11-29 12:49:23 -08:00
API versions are specified by submitting an additional HTTP ` Accept`
header with every request:
` ``
2026-03-09 15:36:22 -07:00
Accept: application/json; version=10
2022-11-29 12:49:23 -08:00
` ``
2026-03-09 15:36:22 -07:00
If an invalid version is specified, Paperless responds with
` 406 Not Acceptable` and an error message in the body.
2022-11-29 12:49:23 -08:00
If a client wishes to verify whether it is compatible with any given
server, the following procedure should be performed:
2026-03-09 15:36:22 -07:00
1. Perform an _authenticated_ request against any API endpoint. The
server will add two custom headers to the response:
2022-11-29 12:49:23 -08:00
` ``
2026-03-09 15:36:22 -07:00
X-Api-Version: 10
X-Version: <server-version>
2022-11-29 12:49:23 -08:00
` ``
2. Determine whether the client is compatible with this server based on
the presence/absence of these headers and their values if present.
2025-01-27 07:34:23 -08:00
### API Version Deprecation Policy
Older API versions are guaranteed to be supported for at least one year
after the release of a new API version. After that, support for older
API versions may be (but is not guaranteed to be) dropped.
2022-11-29 12:49:23 -08:00
### API Changelog
#### Version 1
Initial API version.
#### Version 2
2026-03-12 16:29:57 +00:00
- Added field ` Tag.color`. This read/write string field contains a hex
color such as ` #a6cee3 `.
- Added read-only field ` Tag.text_color`. This field contains the text
color to use for a specific tag, which is either black or white
depending on the brightness of ` Tag.color`.
- Removed field ` Tag.colour`.
2024-02-01 11:56:57 -08:00
#### Version 3
2026-03-12 16:29:57 +00:00
- Permissions endpoints have been added.
- The format of the ` /api/ui_settings/` has changed.
2024-02-01 11:56:57 -08:00
#### Version 4
2026-03-12 16:29:57 +00:00
- Consumption templates were refactored to workflows and API endpoints
changed as such.
2024-11-20 12:25:53 -08:00
#### Version 5
2026-03-12 16:29:57 +00:00
- Added bulk deletion methods for documents and objects.
2024-11-20 12:25:53 -08:00
#### Version 6
2026-03-12 16:29:57 +00:00
- Moved acknowledge tasks endpoint to be under ` /api/tasks/acknowledge/`.
2025-01-27 07:34:23 -08:00
#### Version 7
2026-03-12 16:29:57 +00:00
- The format of select type custom fields has changed to return the options
as an array of objects with ` id` and ` label` fields as opposed to a simple
list of strings. When creating or updating a custom field value of a
document for a select type custom field, the value should be the ` id` of
the option whereas previously was the index of the option.
2025-04-19 15:12:55 -07:00
#### Version 8
2026-03-12 16:29:57 +00:00
- The user field of document notes now returns a simplified user object
rather than just the user ID.
2025-05-19 09:38:01 -07:00
#### Version 9
2026-03-12 16:29:57 +00:00
- The document ` created` field is now a date, not a datetime. The
` created_date` field is considered deprecated and will be removed in a
future version.
2026-03-04 14:15:43 -08:00
#### Version 10
2026-03-12 16:29:57 +00:00
- The ` show_on_dashboard` and ` show_in_sidebar` fields of saved views have been
removed. Relevant settings are now stored in the UISettings model. Compatibility is maintained
for versions < 10 until support for API v9 is dropped.
- Document-editing operations such as ` merge`, ` rotate`, and ` edit_pdf` have been
moved from the bulk edit endpoint to their own individual endpoints. Using these methods via
the bulk edit endpoint is still supported for compatibility with versions < 10 until support
for API v9 is dropped.
2026-03-31 07:55:59 -07:00
- The ` all` parameter of list endpoints is now deprecated and will be removed in a future version.
- The bulk edit objects endpoint now supports ` all` and ` filters` parameters to avoid having to send
large lists of object IDs for operations affecting many objects.
2026-04-03 13:53:45 -07:00
- The legacy ` title_content` document search parameter is deprecated and will be removed in a future version.
Clients should use ` text` for simple title-and-content search and ` title_search` for title-only search.
2026-06-18 16:20:31 -07:00
- The task tracking system was redesigned. The tasks list (` /api/tasks/`) is now paginated, and the
task object exposes ` task_type` (formerly ` task_name`) and ` trigger_source` (formerly ` type`). New
read-only endpoints ` /api/tasks/summary/`, ` /api/tasks/status_counts/`, and ` /api/tasks/active/`
provide aggregate views, and ` POST /api/tasks/run/` lets privileged users dispatch supported tasks.
API v9 continues to serve the unpaginated list with the legacy field names until support for v9 is
dropped.