Skip to main content
Skip table of contents

Create, seal or sign and download new PDF document

Introduction

In this scenario, the goal is to create and seal (or sign) new PDF document and download the completed file. To achieve this, the following steps will be taken:

  • Upload a file: The first step is to create a file that will be used to store the PDF document.

  • Create document: New PDF document will be created.

  • Retrieve document: Once the document has been created, it will be retrieved from the storage to show additional data needed in following steps.

  • Seal or sign the document: The PDF document will be sealed or signed to ensure its authenticity and prevent any unauthorized modifications. This can be done using various techniques such as adding digital signatures or applying certification. Once the document is sealed or signed, it will be ready for distribution or download.

    To clearly understand difference between seal and sign please read following article - What is the difference between a signature and a seal?

  • Download: Once the document is completed it is now ready to be downloaded from Circularo to your local storage or integration software.

Step 1 - Sign in (optional)

Sign user in.

Please note that this step is optional, we recommend you create an API key to be used as a token with all requests - Create new API key

Read more about authentication - Authentication

Endpoint

CODE
POST /login

Request

JSON
POST /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 YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L.

  • signatureFileId - In response object at position user.config.signature[0].imageId.

    • It may have value of OO8YzfomqbUl9vXeIlkNQicltcu0w8n2JeVAdy2r0KGfCJN1xd3H3s3mnY5iVwTU.

Step 2 - Upload file

Upload new PDF file to the Circularo storage from which the document will be created.

Read more about file creation - Create file

Endpoint

CODE
POST /files/saveFile

Request

JSON
POST /files/saveFile?token=YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L

Content-Type: multipart/form-data

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

Response

Note following properties in response object:

  • fileHash - In response object at position file.id.

    • It may have value of fXWAuB5F4oGkdWWCORcAj1oZ6LfD1QIaOfrn3LdFSdyNaueHqjlzImWydnoI7iJE.

The file is now created.

Step 3 - Create document from file

Create new document from existing PDF file in storage.

Read more about document creation - Create document

Read more about Circularo documents - Document structure

Endpoint

CODE
POST /documents

Request

JSON
POST /documents?token=YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L

Content-Type: application/json

{
  "body": {
    "documentType": "d_default",
    "documentTitle": "My Document",
    "pdfFile": {
      "content": "fXWAuB5F4oGkdWWCORcAj1oZ6LfD1QIaOfrn3LdFSdyNaueHqjlzImWydnoI7iJE"  //specify existing file hash
    }
  },
  "definitionType": "ext",
  "workflow": "wf_archive",
  "optionalData": {
    "folder": "925540ac-e9d8-408e-b817-e41fc1737db2"  //optional - specify to which folder document will be placed
  }
}

Response

Note following properties in response object:

  • documentId - In response object at position results[0].documentId.

    • It may have value of cd52bf07-cdd2-4d3d-81e0-9677e65b4110.

The PDF document is now created.

Step 4 - Retrieve document info

Retrieve document information. This step is required in order to obtain document version which is needed in following requests.

Read more about document retrieval - Retrieve the document

Endpoint

CODE
GET /documents/:documentId

Request

JSON
GET /documents/cd52bf07-cdd2-4d3d-81e0-9677e65b4110?token=YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L

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 additional information about the document.

If any of following endpoint 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 5A - Seal the document

Put a seal on the document = apply electronic certificate

Read more about document seal - Seal the document

Endpoint

CODE
PUT /documents/seal/:documentVersion

Path parameters:

  • documentVersion - Document version taken from previous step.

Request

JSON
PUT /documents/seal/6?token=YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L

Content-Type: application/json

{
  "id": "cd52bf07-cdd2-4d3d-81e0-9677e65b4110",
  "certificate": true
}

Step 5B - Sign the document

Apply electronic certificate and insert image of your signature.

Read more about document signing - Sign the document

Endpoint

CODE
PUT /documents/sign/:documentVersion

Path parameters:

  • documentVersion - Document version taken from previous step.

Request

JSON
PUT /documents/sign/6?token=YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L

Content-Type: application/json

{
  "signatures": [
    {
      "pages": [  //specify on which page should the signature be placed
        1
      ],
      "position": {  //position and size of the signature in the document page
        "percentX": 0.5336425978217023,
        "percentY": 0.2360980475986889,
        "percentWidth": 0.3910665378654381,
        "percentHeight": 0.1
      },
      "blob": "OO8YzfomqbUl9vXeIlkNQicltcu0w8n2JeVAdy2r0KGfCJN1xd3H3s3mnY5iVwTU",  //signature image
      "decorationType": "empty",
      "type": "signature",  //other possible types: initials, stamp, wacom, annotation, and image
      "timestamp": false  //if true places timestamp under the signature
    }
  ],
  "id": "cd52bf07-cdd2-4d3d-81e0-9677e65b4110"  //ID of the document you want to sign
}

Step 6 - Download signed document

Download completed document with electronic certificate or inserted signature.

Read more about document download - Download document file

Endpoint

CODE
GET /files/loadFile/hash/:hash

Path parameters:

  • hash - The file hash of the document you want to download.

Request

JSON
GET /files/loadFile/hash/fXWAuB5F4oGkdWWCORcAj1oZ6LfD1QIaOfrn3LdFSdyNaueHqjlzImWydnoI7iJE?token=YpSPghofcbnK7ljeDw6ePnr8fDJMyf5Ry4y0qt7vBd48wCxvkV31IweT2j7qzy7L

The response of the API call will be the main file of the specified document.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.