Password-Protected PDFs

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


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


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:

HTTP/1.1 403 Forbidden

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