Skip to main content
Skip table of contents

Sign document and request signature

Introduction

In this scenario, the goal is to upload a file, create a document, sign it and share it with the intended recipients for signature. The scenario should demonstrate Circularo possibility to place and request signature at the same time (in one request). 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.

  • Sign and request signature (share for signature): In this step we place our signature and specify the recipients who need to sign the document.

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 uelCMl7RI6kuAOEKHhc6IFl9EoIT5ZbwWOjdssIt3z25U4dGOzqhGlckGPdcUArk.

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

    • It may have value of 8I6jjrWMIDtK1KJooT1vYZJoq4YU8fmU9QdsVfqLxVUyumky1rfQXN9DBOnqr5Z2.

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=uelCMl7RI6kuAOEKHhc6IFl9EoIT5ZbwWOjdssIt3z25U4dGOzqhGlckGPdcUArk

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 AVbMmWK0eh3zybGCkwfM35XgdFGQYcVrofpHIzXhTFJHfrTYhy9Ws59ieV6u0myP.

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=uelCMl7RI6kuAOEKHhc6IFl9EoIT5ZbwWOjdssIt3z25U4dGOzqhGlckGPdcUArk

Content-Type: application/json

{
  "body": {
    "documentType": "d_default",
    "documentTitle": "My Document",
    "pdfFile": {
      "content": "AVbMmWK0eh3zybGCkwfM35XgdFGQYcVrofpHIzXhTFJHfrTYhy9Ws59ieV6u0myP"  //specify existing file hash
    }
  },
  "definitionType": "ext",
  "workflow": "wf_archive",
  "optionalData": {
    "folder": "43fedb1d-7db4-467e-9005-99170eb52ec9"  //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 0aeb3800-e7e3-48c3-82a4-9ecf77b1ba7b.

The PDF document is now created.

Step 4 - Sign and request signature

This step combines 2 requests that can be performed on the document - sign and request signature.

Read more about sign and signature request: Sign the document

Request signature

We will be requesting signature from an internal user and add a field with his phone number next to the signature.

Endpoint

CODE
POST /share

Request

JSON
POST /share?token=uelCMl7RI6kuAOEKHhc6IFl9EoIT5ZbwWOjdssIt3z25U4dGOzqhGlckGPdcUArk

Content-Type: application/json

{
  "id": "0aeb3800-e7e3-48c3-82a4-9ecf77b1ba7b",
  "type": "d_default",
  "objectType": "document",
  "data": [
    {
      "sharePurpose": "sign",
      "shareTo": "derek.trotter@circularo.com"
    }
  ],
  "signatureFields": [  //array with objects that are required from the user
    {
      "user": [
        "derek.trotter@circularo.com"
      ],
      "timestamp": false,
      "required": true,
      "type": "signature",  //type is signature
      "pages": [  //document page with signature
        1
      ],
      "position": {  //position and size of the signature in the document page
        "percentX": 0.2,
        "percentY": 0.6,
        "percentWidth": 0.4,
        "percentHeight": 0.1
      }
    },
    {
      "user": [
        "derek.trotter@circularo.com"
      ],
      "required": true,
      "type": "annotation",  //type is annotation
      "subtype": "annotation_phone",  //subtype is phone
      "pages": [
        1
      ],
      "position": {  //position and size of the annotation in the document page
        "percentX": 0.6,
        "percentY": 0.6,
        "percentWidth": 0.1,
        "percentHeight": 0.15
      }
    }
  ],
  "signatures": [  //array containing our signature
    {
      "type": "signature",
      "blob": "8I6jjrWMIDtK1KJooT1vYZJoq4YU8fmU9QdsVfqLxVUyumky1rfQXN9DBOnqr5Z2",
      "pages": [
        1
      ],
      "position": {
        "percentX": 0.5,
        "percentY": 0.3,
        "percentWidth": 0.4,
        "percentHeight": 0.1
      },
      "disableDecoration": true
    }
  ]
}

Response

JSON
[
  {
    "shareId": "09jE3AYcBXD1D2IusrOb",
    "isActive": true,
    "isPermanentViewToken": false,
    "messageRead": false,
    "shareDate": "2023-07-20T14:04:36.186Z",
    "shareType": "sign",
    "sharedBy": "mary.griffin@circularo.com",
    "sharedObjectEsId": "0aeb3800-e7e3-48c3-82a4-9ecf77b1ba7b",
    "sharedObjectEsType": "d_default",
    "sharedObjectType": "document",
    "sharedWith": [
      "derek.trotter@circularo.com"
    ],
    "passwordRequired": false,
    "sharedUsername": "derek.trotter@circularo.com",
    "sequential": false,
    "isDelegated": false,
    "shareGroup": "e742f059-c5f5-49a6-bad0-0f0c9b41fcd2",
    "rights": [
      "print",
      "delegate",
      "metadata",
      "canAnnotateOnReject"
    ],
    "sendAttachmentsOnComplete": false,
    "dateFormat": "dd/MM/yyyy",
    "timeFormat": "h:mm a",
    "isMandatory": true,
    "tokenGenerated": false
  }
]

Document is now signed with our signature and sent to Derek Edward Trotter who needs to fill in his phone and sign the document.

JavaScript errors detected

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

If this problem persists, please contact our support.