Create eDoc in folder and sign it

Circularo REST API example

Create eDoc document inside new folder. Then sign it using already existing signature.

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 “tqZPCFgJ7UAhvnFQqtU2QY6GoTSoUmEYTJsrZkzhEibk8pub1KfRWhool3BqWUYK“.
  • signatureFileId - In response object at position ‘user.config.signature[0].imageId‘. It may have value of “eEcl4H74HQDkkLuqtogdCD33rJ1m4tKbPbtvIeYHgq8NPKNkLQgWKdluF4Tutbli“.

Step 2 - Create root folder

Create new shared folder in root. Use ‘“isShared”: false’ to create private folder.

Endpoint

POST - /folders

Example

/folders?token=tqZPCFgJ7UAhvnFQqtU2QY6GoTSoUmEYTJsrZkzhEibk8pub1KfRWhool3BqWUYK

Content-Type: application/json

{
  "name": "My root folder",
  "isShared": true,
  "parentFolderId": null
}

Response

Note following properties in response object:

  • rootFolderId - In response object at position ‘id‘. It may have value of “48eac8c9-72b4-428c-9367-01125efe1ad6“.

The folder is now created. All nested folders must be shared as well.

Step 3 - Create new nested eDoc document

Create new eDoc document inside the folder. eDoc is created from “documentType” HTML template and user inputs.

If you don’t want tu put the document to the folder, don’t specify the “folder” in optional data’.

“D_BLANK_TEXTAREA” is document type specific variable.

Endpoint

POST - /documents

Example

/documents?token=tqZPCFgJ7UAhvnFQqtU2QY6GoTSoUmEYTJsrZkzhEibk8pub1KfRWhool3BqWUYK

Content-Type: application/json

{
  "body": {
    "documentType": "d_blank",
    "documentTitle": "My nested document",
    "D_BLANK_TEXTAREA": "Definition specific field value."
  },
  "definitionType": "edoc",
  "workflow": "wf_archive",
  "optionalData": {
    "folder": "48eac8c9-72b4-428c-9367-01125efe1ad6"
  }
}

Response

Note following properties in response object:

  • documentId - In response object at position ‘results[0].documentId‘. It may have value of “a5c4c3e5-6c7b-4e60-9984-accae4f0c264“.

The document is now created.

Step 4 - Sign document

Sign selected document. “blob” is signature file id. If document has been just created, you can use ‘“documentVersion”: 1’.

Endpoint

PUT - /documents/sign/:documentVersion

Example

/documents/sign/1?token=tqZPCFgJ7UAhvnFQqtU2QY6GoTSoUmEYTJsrZkzhEibk8pub1KfRWhool3BqWUYK

Content-Type: application/json

{
  "id": "a5c4c3e5-6c7b-4e60-9984-accae4f0c264",
  "type": "d_blank",
  "signatures": [
    {
      "type": "signature",
      "blob": "eEcl4H74HQDkkLuqtogdCD33rJ1m4tKbPbtvIeYHgq8NPKNkLQgWKdluF4Tutbli",
      "page": 1,
      "position": {
        "percentX": 0.5,
        "percentY": 0.3,
        "percentWidth": 0.4,
        "percentHeight": 0.1
      },
      "disableDecoration": true
    }
  ],
  "annotations": [
    {
      "align": "left",
      "backgroundColor": "#ffffff",
      "bold": false,
      "color": "#000000",
      "fontSize": 8,
      "page": 1,
      "percentX": 0.5,
      "percentY": 0.9,
      "percentWidth": 0.2,
      "percentHeight": 0.01,
      "subtype": "docId",
      "text": "{{{documentId}}}"
    }
  ]
}

The document is now signed.

Step 5 - Sign out (Optional)

Sign user out.

Endpoint

GET - /logout

Example

/logout?token=tqZPCFgJ7UAhvnFQqtU2QY6GoTSoUmEYTJsrZkzhEibk8pub1KfRWhool3BqWUYK

eDoc document is now created and signed.