Import and Export Instant JSON PDF Annotation Data
You can import and export annotations from documents you’ve uploaded to Document Engine. One of the supported formats for this is Instant JSON. This guide explains how to import and export annotations in the Instant JSON format.
Exporting Instant JSON
You can export the current annotations of a document as an Instant JSON file via a GET
request to /api/documents/:document_id/document.json
. To get the current annotations of a layer, send a GET
request to /api/documents/:document_id/layers/:layer_name/document.json
:
Request
GET /api/documents/:document_id/document.jsonAuthorization: Token token="<secret token>"
$ curl "http://localhost:5000/api/documents/abc/document.json" \ -H "Authorization: Token token=<secret token>"
Response
HTTP/1.1 200 OKContent-Type: application/json
<JSON data>
Importing Instant JSON
Document Engine supports importing annotations from an Instant JSON file when uploading a document via the /api/documents
endpoint. Send a multipart/form-data
POST
request, including the PDF and the Instant JSON file, to import the annotations in the given PDF file. This will replace all existing annotations in the uploaded PDF with the annotations from the uploaded Instant JSON file. If you want to add annotations to already existing ones instead of replacing them, you can set keep_current_annotations
to true
:
Request
POST /api/documentsContent-Type: multipart/form-data; boundary=customboundaryAuthorization: Token token="<secret token>"
--customboundaryContent-Disposition: form-data; name="file"; filename="Example Document.pdf"Content-Type: application/pdf
<PDF data>--customboundaryContent-Disposition: form-data; name="attachment"; filename="attachment.json"Content-Type: application/json
<annotations data>--customboundary
Importing Instant JSON on Existing Documents
Document Engine supports importing annotations from an Instant JSON file on an existing document via three different endpoints:
POST /apply_instant_json
(opens in a new tab) receives aninstant.json
file and updates the document in place using theinstant.json
file.POST /pdf_with_instant_json
(opens in a new tab) receives aninstant.json
file and responds with the resulting PDF of the document/layer and the importedinstant.json
.POST /copy_with_instant_json
(opens in a new tab) can optionally receive aninstant.json
file and will persist the resulting PDF of the document/layer and the importedinstant.json
file as a new document. The JSON response will include thedocument_id
of the document.