shamoon f674183593 Squashed commit of the following:
commit 80ff5677eacec9271f342525155c250d9245c54c
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Mon Dec 4 06:40:17 2023 -0800

    Fix: bulk edit object permissions should use permissions object (#4797)

commit 62c417cd5189be0b93e3c0529326609f9d1e4f40
Author: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
Date:   Sun Dec 3 19:09:02 2023 -0800

    Fixes the 0023 migration to include the new help text and verbose name

commit f27f25aa03d032ad7ca6a5f2ba41f83bd00c0bd7
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sun Dec 3 15:35:30 2023 -0800

    Enhancement: support assigning custom fields via consumption templates (#4727)

commit 285a4b5aef0aa4676ee66751a381e77a9e9fcdcf
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sun Dec 3 12:57:43 2023 -0800

    Fix: empty strings for consumption template fields should be treated as None (#4762)

commit 47a2ded30d7e77f2a264b187821af001232ce3d5
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sat Dec 2 16:52:48 2023 -0800

    Fix: use default permissions for objects created via dropdown (#4778)

commit 5b502b1e1a34528b59a0af0a01e73a1f9e7c0656
Author: Trenton H <797416+stumpylog@users.noreply.github.com>
Date:   Sat Dec 2 16:18:06 2023 -0800

    Use the original image file for the checksum, not the maybe alpha removed version (#4781)

commit aff56077a8ac4d4ec78860d52b824961fada847b
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sat Dec 2 08:26:42 2023 -0800

    Feature: update user profile (#4678)

commit 6e371ac5ac2227a6bdef5e15483f5b478ba78c4d
Author: Trenton H <797416+stumpylog@users.noreply.github.com>
Date:   Sat Dec 2 08:26:19 2023 -0800

    Enhancement: Allow excluding mail attachments by name (#4691)

    * Adds new filtering to exclude attachments from processing

    * Frontend use include / exclude mail rule filename filters

    ---------

    Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>

commit 1b69b89d2dd4ec021aa6e3bceb175340cdd4e0ff
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sat Dec 2 08:24:17 2023 -0800

    Chore: Remove unneeded .env entry, revert crowdin action rm, reduce frequency

commit 5a20c8e512a7c8a45c26eed5f9e0cf3b1bb04661
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sat Dec 2 07:56:56 2023 -0800

    Fix version checker GitHub api url (#4773)

commit 4ca1503beb1c65eb4f77ac992b4b3ea74fbc6fd4
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sat Dec 2 07:47:57 2023 -0800

    Fix: Limit global drag-drop to events with files (#4767)

commit 20f27fe32ffe144813d6c69e3326bf230a2da52a
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 1 18:05:43 2023 -0800

    Remove the pngx .env file for crowdin action

commit 1a50d6bb8624a3dd419cadb48e4ee5416fd46ce6
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 2 02:04:16 2023 +0000

    Bump the actions group with 2 updates (#4745)

    Bumps the actions group with 2 updates: [actions/github-script](https://github.com/actions/github-script) and [stumpylog/image-cleaner-action](https://github.com/stumpylog/image-cleaner-action).

    Updates `actions/github-script` from 6 to 7
    - [Release notes](https://github.com/actions/github-script/releases)
    - [Commits](https://github.com/actions/github-script/compare/v6...v7)

    Updates `stumpylog/image-cleaner-action` from 0.3.0 to 0.4.0
    - [Release notes](https://github.com/stumpylog/image-cleaner-action/releases)
    - [Changelog](https://github.com/stumpylog/image-cleaner-action/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/stumpylog/image-cleaner-action/compare/v0.3.0...v0.4.0)

    ---
    updated-dependencies:
    - dependency-name: actions/github-script
      dependency-type: direct:production
      update-type: version-update:semver-major
      dependency-group: actions
    - dependency-name: stumpylog/image-cleaner-action
      dependency-type: direct:production
      update-type: version-update:semver-minor
      dependency-group: actions
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 0b16c2db0372535d18e75267f0a26e4d7f4c812a
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 1 17:54:00 2023 -0800

    Update crowdin action triggers

commit 76ac8883865e123bb48f80336cc0658f7d913249
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 1 17:44:33 2023 -0800

    Chore: Implement crowdin GHA (#4706)

commit 7cfa05d7f2c63d2a1c25eb4e0b54ad3a52726a59
Author: Paperless-ngx Bot [bot] <99855517+paperlessngx-bot@users.noreply.github.com>
Date:   Fri Dec 1 17:44:05 2023 -0800

    New Crowdin updates (#4729)

commit e3496d04858337a193b623fabc8cc49ec0dc08cf
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 2 01:07:13 2023 +0000

    Bump the frontend-eslint-dependencies group in /src-ui with 3 updates (#4756)

    Bumps the frontend-eslint-dependencies group in /src-ui with 3 updates: [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin), [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) and [eslint](https://github.com/eslint/eslint).

    Updates `@typescript-eslint/eslint-plugin` from 6.9.1 to 6.13.1
    - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
    - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
    - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.13.1/packages/eslint-plugin)

    Updates `@typescript-eslint/parser` from 6.9.1 to 6.13.1
    - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
    - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
    - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.13.1/packages/parser)

    Updates `eslint` from 8.52.0 to 8.55.0
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/eslint/eslint/compare/v8.52.0...v8.55.0)

    ---
    updated-dependencies:
    - dependency-name: "@typescript-eslint/eslint-plugin"
      dependency-type: direct:development
      update-type: version-update:semver-minor
      dependency-group: frontend-eslint-dependencies
    - dependency-name: "@typescript-eslint/parser"
      dependency-type: direct:development
      update-type: version-update:semver-minor
      dependency-group: frontend-eslint-dependencies
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
      dependency-group: frontend-eslint-dependencies
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit d2c33c00746ecc4ceba35a1ce5339354fdbf20ea
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 2 00:58:27 2023 +0000

    Bump the frontend-jest-dependencies group in /src-ui with 2 updates (#4744)

    Bumps the frontend-jest-dependencies group in /src-ui with 2 updates: [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) and [jest-preset-angular](https://github.com/thymikee/jest-preset-angular).

    Updates `@types/jest` from 29.5.7 to 29.5.10
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

    Updates `jest-preset-angular` from 13.1.2 to 13.1.4
    - [Release notes](https://github.com/thymikee/jest-preset-angular/releases)
    - [Changelog](https://github.com/thymikee/jest-preset-angular/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/thymikee/jest-preset-angular/compare/v13.1.2...v13.1.4)

    ---
    updated-dependencies:
    - dependency-name: "@types/jest"
      dependency-type: direct:development
      update-type: version-update:semver-patch
      dependency-group: frontend-jest-dependencies
    - dependency-name: jest-preset-angular
      dependency-type: direct:development
      update-type: version-update:semver-patch
      dependency-group: frontend-jest-dependencies
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 9c5caecafadc6f28e414117ba7be329243863608
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 2 00:49:46 2023 +0000

    Bump @playwright/test from 1.39.0 to 1.40.1 in /src-ui (#4749)

    Bumps [@playwright/test](https://github.com/microsoft/playwright) from 1.39.0 to 1.40.1.
    - [Release notes](https://github.com/microsoft/playwright/releases)
    - [Commits](https://github.com/microsoft/playwright/compare/v1.39.0...v1.40.1)

    ---
    updated-dependencies:
    - dependency-name: "@playwright/test"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 64651d5a8424488ad4878bb61098376c550d892e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 2 00:38:35 2023 +0000

    Bump wait-on from 7.0.1 to 7.2.0 in /src-ui (#4747)

    Bumps [wait-on](https://github.com/jeffbski/wait-on) from 7.0.1 to 7.2.0.
    - [Release notes](https://github.com/jeffbski/wait-on/releases)
    - [Commits](https://github.com/jeffbski/wait-on/compare/v7.0.1...v7.2.0)

    ---
    updated-dependencies:
    - dependency-name: wait-on
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 4493236879bcc70aa3e4b6be769a543d9ada239d
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Dec 1 16:28:50 2023 -0800

    Bump @types/node from 20.8.10 to 20.10.2 in /src-ui (#4748)

    Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.8.10 to 20.10.2.
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

    ---
    updated-dependencies:
    - dependency-name: "@types/node"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit ce643942ea4f2635a13c22e34a933b254647d560
Author: omahs <73983677+omahs@users.noreply.github.com>
Date:   Fri Dec 1 15:55:03 2023 +0100

    Documentation: Fix typos (#4737)

commit 46d216b02f35abb5fdbed0539984b8d262192e01
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 23:14:59 2023 -0800

    Remove project actions in favor of GH workflows

commit 133d43ae3057bceb56cbedaf96742ce62c0d7930
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 19:08:03 2023 -0800

    Enhancement: auto-refresh logs & tasks (#4680)

commit 27155cb7e3230a6909ff9b339e41bf423fb08e64
Author: Trenton H <797416+stumpylog@users.noreply.github.com>
Date:   Thu Nov 30 17:12:14 2023 -0800

    Fixes the image cleaner not running for the registry cache (#4732)

commit 69be86e16c956e2129baef318e76a5f4cadf8b7a
Author: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
Date:   Thu Nov 30 07:11:46 2023 -0800

    Resets version string to 2.0.1-dev

commit 65f6b0881ea2dce37a9c8b8ee079278e4fd81865
Author: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
Date:   Thu Nov 30 07:11:00 2023 -0800

    Bumps version to 2.0.1

commit c2bede40c7094e46f49640790cf2267bd273dadd
Merge: 6575c6940 33c2398de
Author: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
Date:   Thu Nov 30 07:10:29 2023 -0800

    Merge remote-tracking branch 'origin/dev'

commit 33c2398de949dd4ee97b08736e5964efab2fcc01
Author: Paperless-ngx Bot [bot] <99855517+paperlessngx-bot@users.noreply.github.com>
Date:   Thu Nov 30 07:08:10 2023 -0800

    New Crowdin updates (#4695)

commit 64cfc43891fbc7da692c138e73922d45b2e12c8c
Author: Trenton H <797416+stumpylog@users.noreply.github.com>
Date:   Thu Nov 30 07:00:54 2023 -0800

    Inreases the length to 5, allowing for commas as well as values (#4719)

commit 6575c69409afeb68f70fd602832e15c9d0701bc2
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Wed Nov 29 21:56:05 2023 -0800

    Fix: restore docs search

commit e3f4e0b77572a9a784f748a79aa78c25388fb77c
Author: Trenton H <797416+stumpylog@users.noreply.github.com>
Date:   Wed Nov 29 12:18:44 2023 -0800

    Adds new setting to control color conversions (#4709)

commit 5be89bfda5228e19351387351b27ece458528317
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Nov 29 11:50:30 2023 -0800

    Changelog v2.0.0 - GHA (#4693)

    Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

commit e1b573adeb3f9b644fb51bd9359b51922df10732
Author: Trenton H <797416+stumpylog@users.noreply.github.com>
Date:   Wed Nov 29 11:28:27 2023 -0800

    Fix: Add a warning about a low image DPI which may cause OCR to fail (#4708)

commit 0913c7aa9efbd071bd5c423b5d5de5cf12617185
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Wed Nov 29 11:10:55 2023 -0800

    Fix: share links for URLs containing 'api' incorrect in dropdown (#4701)
2023-12-04 17:13:00 -08:00

380 lines
13 KiB
Markdown

# The REST API
Paperless makes use of the [Django REST
Framework](https://django-rest-framework.org/) standard API interface. It
provides a browsable API for most of its endpoints, which you can
inspect at `http://<paperless-host>:<port>/api/`. This also documents
most of the available filters and ordering fields.
The API provides the following main endpoints:
- `/api/documents/`: Full CRUD support, except POSTing new documents.
See below.
- `/api/correspondents/`: Full CRUD support.
- `/api/document_types/`: Full CRUD support.
- `/api/logs/`: Read-Only.
- `/api/tags/`: Full CRUD support.
- `/api/tasks/`: Read-only.
- `/api/mail_accounts/`: Full CRUD support.
- `/api/mail_rules/`: Full CRUD support.
- `/api/users/`: Full CRUD support.
- `/api/groups/`: Full CRUD support.
- `/api/share_links/`: Full CRUD support.
- `/api/custom_fields/`: Full CRUD support.
- `/api/profile/`: GET, PATCH
All of these endpoints except for the logging endpoint allow you to
fetch (and edit and delete where appropriate) individual objects by
appending their primary key to the path, e.g. `/api/documents/454/`.
The objects served by the document endpoint contain the following
fields:
- `id`: ID of the document. Read-only.
- `title`: Title of the document.
- `content`: Plain text content of the document.
- `tags`: List of IDs of tags assigned to this document, or empty
list.
- `document_type`: Document type of this document, or null.
- `correspondent`: Correspondent of this document or null.
- `created`: The date time at which this document was created.
- `created_date`: The date (YYYY-MM-DD) at which this document was
created. Optional. If also passed with created, this is ignored.
- `modified`: The date at which this document was last edited in
paperless. Read-only.
- `added`: The date at which this document was added to paperless.
Read-only.
- `archive_serial_number`: The identifier of this document in a
physical document archive.
- `original_file_name`: Verbose filename of the original document.
Read-only.
- `archived_file_name`: Verbose filename of the archived document.
Read-only. Null if no archived document is available.
- `notes`: Array of notes associated with the document.
- `set_permissions`: Allows setting document permissions. Optional,
write-only. See [below](#permissions).
- `custom_fields`: Array of custom fields & values, specified as
{ field: CUSTOM_FIELD_ID, value: VALUE }
## Downloading documents
In addition to that, the document endpoint offers these additional
actions on individual documents:
- `/api/documents/<pk>/download/`: Download the document.
- `/api/documents/<pk>/preview/`: Display the document inline, without
downloading it.
- `/api/documents/<pk>/thumb/`: Download the PNG thumbnail of a
document.
Paperless generates archived PDF/A documents from consumed files and
stores both the original files as well as the archived files. By
default, the endpoints for previews and downloads serve the archived
file, if it is available. Otherwise, the original file is served. Some
document cannot be archived.
The endpoints correctly serve the response header fields
`Content-Disposition` and `Content-Type` to indicate the filename for
download and the type of content of the document.
In order to download or preview the original document when an archived
document is available, supply the query parameter `original=true`.
!!! tip
Paperless used to provide these functionality at `/fetch/<pk>/preview`,
`/fetch/<pk>/thumb` and `/fetch/<pk>/doc`. Redirects to the new URLs are
in place. However, if you use these old URLs to access documents, you
should update your app or script to use the new URLs.
## Getting document metadata
The api also has an endpoint to retrieve read-only metadata about
specific documents. this information is not served along with the
document objects, since it requires reading files and would therefore
slow down document lists considerably.
Access the metadata of a document with an ID `id` at
`/api/documents/<id>/metadata/`.
The endpoint reports the following data:
- `original_checksum`: MD5 checksum of the original document.
- `original_size`: Size of the original document, in bytes.
- `original_mime_type`: Mime type of the original document.
- `media_filename`: Current filename of the document, under which it
is stored inside the media directory.
- `has_archive_version`: True, if this document is archived, false
otherwise.
- `original_metadata`: A list of metadata associated with the original
document. See below.
- `archive_checksum`: MD5 checksum of the archived document, or null.
- `archive_size`: Size of the archived document in bytes, or null.
- `archive_metadata`: Metadata associated with the archived document,
or null. See below.
File metadata is reported as a list of objects in the following form:
```json
[
{
"namespace": "http://ns.adobe.com/pdf/1.3/",
"prefix": "pdf",
"key": "Producer",
"value": "SparklePDF, Fancy edition"
}
]
```
`namespace` and `prefix` can be null. The actual metadata reported
depends on the file type and the metadata available in that specific
document. Paperless only reports PDF metadata at this point.
## Documents additional endpoints
- `/api/documents/<id>/notes/`: Retrieve notes for a document.
- `/api/documents/<id>/share_links/`: Retrieve share links for a document.
## Authorization
The REST api provides three different forms of authentication.
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
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.
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>
```
Tokens can also be managed in the Django admin.
## Searching for documents
Full text searching is available on the `/api/documents/` endpoint. Two
specific query parameters cause the API to return full text search
results:
- `/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=1234`: Search for documents similar to
the document with id 1234.
Pagination works exactly the same as it does for normal requests on this
endpoint.
Certain limitations apply to full text queries:
- Results are always sorted by search score. The results matching the
query best will show up first.
- Only a small subset of filtering parameters are supported.
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
}
},
...
]
}
```
- `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.
### `/api/search/autocomplete/`
Get auto completions for a partial search term.
Query parameters:
- `term`: The incomplete term.
- `limit`: Amount of results. Defaults to 10.
Results returned by the endpoint are ordered by importance of the term
in the document index. The first result is the term that has the highest
[Tf/Idf](https://en.wikipedia.org/wiki/Tf%E2%80%93idf) score in the index.
```json
["term1", "term3", "term6", "term4"]
```
## POSTing documents {#file-uploads}
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:
- `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.
- `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.
The endpoint will immediately return HTTP 200 if the document consumption
process was started successfully, with the UUID of the consumption task
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.
## Permissions
All objects (documents, tags, etc.) allow setting object-level permissions
with optional `owner` and / or a `set_permissions` parameters which are of
the form:
```
"owner": ...,
"set_permissions": {
"view": {
"users": [...],
"groups": [...],
},
"change": {
"users": [...],
"groups": [...],
},
}
```
!!! note
Arrays should contain user or group ID numbers.
If these parameters are supplied the object's permissions will be overwritten,
assuming the authenticated user has permission to do so (the user must be
the object owner or a superuser).
### 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
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.
## API Versioning
The REST API is versioned since Paperless-ngx 1.3.0.
- 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, older API versions will
always serve compatible data.
- If no version is specified, Paperless will serve version 1 to ensure
compatibility with older clients that do not request a specific API
version.
API versions are specified by submitting an additional HTTP `Accept`
header with every request:
```
Accept: application/json; version=6
```
If an invalid version is specified, Paperless 1.3.0 will respond with
"406 Not Acceptable" and an error message in the body. Earlier
versions of Paperless will serve API version 1 regardless of whether a
version is specified via the `Accept` header.
If a client wishes to verify whether it is compatible with any given
server, the following procedure should be performed:
1. Perform an _authenticated_ request against any API endpoint. If the
server is on version 1.3.0 or newer, the server will add two custom
headers to the response:
```
X-Api-Version: 2
X-Version: 1.3.0
```
2. Determine whether the client is compatible with this server based on
the presence/absence of these headers and their values if present.
### API Changelog
#### Version 1
Initial API version.
#### Version 2
- 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`.