Password-Protected PDFs

Accessing Password-Protected Documents

To access password-protected documents via the API, you need to include the pspdfkit-pdf-password header in all requests that work on a password-protected document.

Example Request

Request

Copy
1
2
3
4
GET http://localhost:500/api/documents/abc/annotations
Authorization: Token token=secret
accept: application/json
pspdfkit-pdf-password: abc
Copy
1
2
3
4
$ curl http://localhost:5000/api/documents/abc/annotations \
   -H "Accept: application/json" \
   -H "Authorization: Token token=<secret token>" \
   -H "pspdfkit-pdf-password: test123"

Response

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "annotations": [
      {"id": "01BS98XZSCFV5QARF948FZWNG5", "content": {...}, "createdBy": "alice", "updatedBy": "bob"},
      {"id": "01BS98Y0A0YDX4A54K04NQPQ6T", "content": {...}, "createdBy": "alice", "updatedBy": "bob"},
      {"id": "01BS98Y0QFZF5K044JVMDD7W0T", "content": {...}, "createdBy": "alice", "updatedBy": "bob"},
      ...
    ],
    "truncated": true
  }
}

When the given password doesn’t match the password of the PDF, the server will respond with an error:

Copy
1
2
3
4
GET http://127.0.0.1:5000/api/documents/abc/annotations
HTTP/1.1 403 Forbidden

Value for 'pspdfkit-pdf-password' header doesn't match document password.