Create and seal new PDF document

Circularo REST API example

Create document from RTF file and automatically convert it to PDF. Then seal it.

Step 1 - Sign in

Sign user in.

Endpoint

POST - /login

Example

/login

Content-Type: application/json

{
  "name": "mary.griffin@circularo.com",
  "password": "#32Password1!",
  "tenant": "default"
}

Response

Note following properties in response object:

  • token - In response object at position ‘token‘. It may have value of “QorV6bR1sf6ezigQtXIX3tDsdJDlh5mOay4qOi54Z6E4Xk2eUriQOq5KfsMfQRV6“.

Step 2 - Create new RTF file

Create new RTF file in the Circularo.

Endpoint

POST - /files/saveFile

Example

/files/saveFile?token=QorV6bR1sf6ezigQtXIX3tDsdJDlh5mOay4qOi54Z6E4Xk2eUriQOq5KfsMfQRV6

Content-Type: multipart/form-data

{
  "file": "blob",
  "fileName": "My RTF file"
}

Response

Note following properties in response object:

  • fileId - In response object at position ‘file.id‘. It may have value of “cJKL0glTHC0vBiSCBLrQrSReEyx8bUJfYdGH4YamewWhv31aaPLkWWHqr65fBWe9“.

The file is now created.

Step 3 - Create PDF document from file

Create new document from existing RTF file. As conversion is switched on, the document is automatically converted to PDF type.

In ‘“definitionType”: “ext”‘ you are always specifying “pdfFile” object, no matter what content type the file is.

Endpoint

POST - /documents

Example

/documents?token=QorV6bR1sf6ezigQtXIX3tDsdJDlh5mOay4qOi54Z6E4Xk2eUriQOq5KfsMfQRV6

Content-Type: application/json

{
  "body": {
    "documentType": "d_default",
    "documentTitle": "My file based document",
    "pdfFile": {
      "content": "cJKL0glTHC0vBiSCBLrQrSReEyx8bUJfYdGH4YamewWhv31aaPLkWWHqr65fBWe9",
      "_content_type": "application/rtf"
    }
  },
  "definitionType": "ext",
  "workflow": "wf_archive",
  "convertToPDF": true
}

Response

Note following properties in response object:

  • documentId - In response object at position ‘results[0].documentId‘. It may have value of “18ef17fe-de84-4093-826a-6864654904dd“.

The PDF document is now created.

Step 4 - Retrieve document

Retrieve document information.

Endpoint

GET - /documents/:documentId

Example

/documents/18ef17fe-de84-4093-826a-6864654904dd?token=QorV6bR1sf6ezigQtXIX3tDsdJDlh5mOay4qOi54Z6E4Xk2eUriQOq5KfsMfQRV6

Response

Note following properties in response object:

  • documentVersion - In response object at position ‘results[0]._version‘. It may have value of 3.

Returned object contains information about the document.

If any of following endpoint calls will require document version and fails with status code ‘409 - Version mismatch’, please call this endpoint again to receive updated document version. There may be some background tasks that change document version after it is created.

Step 5 - Seal document

Seal selected document.

Endpoint

PUT - /documents/seal/:documentVersion

Example

/documents/seal/3?token=QorV6bR1sf6ezigQtXIX3tDsdJDlh5mOay4qOi54Z6E4Xk2eUriQOq5KfsMfQRV6

Content-Type: application/json

{
  "id": "18ef17fe-de84-4093-826a-6864654904dd"
}

The document is now sealed.

Step 6 - Sign out (Optional)

Sign user out.

Endpoint

GET - /logout

Example

/logout?token=QorV6bR1sf6ezigQtXIX3tDsdJDlh5mOay4qOi54Z6E4Xk2eUriQOq5KfsMfQRV6

PDF document is now created and sealed.