Get and update document

Circularo REST API example

Get information about already existing document and get its audit trail. Then update document attachments and labels.

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 “JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0“.

Step 2 - Retrieve document

Retrieve document information.

Endpoint

GET - /documents/:documentId

Example

/documents/6f1abc03-14e5-428b-a236-977d54d656c9?token=JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0

Response

Note following properties in response object:

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

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 3 - Retrieve document audit trail

Retrieve document audit trail by document ID.

Endpoint

GET - /documents/:documentId/audit

Example

/documents/6f1abc03-14e5-428b-a236-977d54d656c9/audit?token=JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0

Returns PDF file with document audit trail.

Step 4 - Create new PDF file

Create new PDF file in the Circularo.

Endpoint

POST - /files/saveFile

Example

/files/saveFile?token=JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0

Content-Type: multipart/form-data

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

Response

Note following properties in response object:

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

The file is now created.

Step 5 - Add attachment to the document

Add selected file attachment to given document.

Endpoint

POST - /attachments/:documentId

Example

/attachments/6f1abc03-14e5-428b-a236-977d54d656c9?token=JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0

Content-Type: application/json

{
  "fileHash": "sNKS00ddIectfIafS0vgBJMwm1o3Ym3UcFboIE2dckyLM9ACn2F8arkaD4t1yutm",
  "document_name": "My PDF file",
  "file_type": "upload"
}

Document now contains given attachment.

Step 6 - Add tags to the document

Add new tags (labels) to given document.

Endpoint

POST - /tags/set/document

Example

/tags/set/document?token=JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0

Content-Type: application/json

{
  "data": [
    {
      "id": "6f1abc03-14e5-428b-a236-977d54d656c9"
    }
  ],
  "tags": {
    "private": [
      "Private tag",
      "Another private tag"
    ],
    "public": [
      "Public tag"
    ]
  }
}

Document now contains given tags.

Step 7 - Sign out (Optional)

Sign user out.

Endpoint

GET - /logout

Example

/logout?token=JlRnvrFLn3KNHFzrM0GSqcpZmHC1Ufdr0qvq7itVhy59ZZHfdDQ6U6SXF92srHA0