Sign Documents with Digital Signatures using REST API in Node.js

You can electronically sign your documents with digital signatures programmatically on the cloud. The digital signatures are used to validate the authenticity and integrity of the documents. It also enables you to attach a code with your document that acts as a signature. This article will be focusing on how to sign documents with digital signatures using a REST API in Node.js.

The following topics shall be covered in this article:

Document Signature REST API and Node.js SDK

For signing PDF and DOCX files, I will be using the Node.js SDK of GroupDocs.Signature Cloud API. It enables you to create, verify and search various types of signatures such as image, ‎barcode, QR-Code, text-based, digital, and stamp signatures. These signatures can easily be applied in portable or simple ‎documents, spreadsheets, presentations, and images of supported file formats. You can integrate the API into your existing Node.js applications. It also provides .NET, Java, PHP, Android, Ruby, and Python SDKs as its document signature family members for the Cloud API.

You can install GroupDocs.Signature Cloud to your Node.js project using the following command in the console:

npm install groupdocs-signature-cloud --save

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add in the code as shown below:

Sign Word Documents using a REST API in Node.js

You can sign Word documents with digital signatures on the Cloud by following the simple steps mentioned below:

Upload the Document

Firstly, upload the Word document to the Cloud using the code example given below:

As a result, the uploaded Word file will be available in the files section of your dashboard on the cloud. Please use the above code sample to upload the certificate and signature image file to the Cloud.

Sign Word Documents with Digital Signatures using Node.js

You can sign your DOCX files with digital signatures programmatically by following the steps given below:

  • Create an instance of the SignApi
  • Create an instance of the FileInfo
  • Set the DOCX file path
  • Create an instance of the SignDigitalOptions
  • Set SignatureType to Digital
  • Set the ImageFilePath and CertificateFilePath
  • Provide the password
  • Set the signature position
  • Create an instance of the SignSettings
  • Assign the SignDigitalOptions and SaveOptions to the SignSettings
  • Create the CreateSignaturesRequest
  • Get results by calling the SignApi.createSignatures() method

The following code example shows how to sign a Word document with digital signatures using a REST API in Node.js.

Sign Word Documents with Digital Signatures using Node.js

Sign Word Documents with Digital Signatures using Node.js

Download the Signed File

The above code sample will save the signed Word file on the cloud. You can download it using the code sample given below:

Sign PDF Documents with Digital Signatures using Node.js

You can sign the PDF documents with digital signatures programmatically by following the steps given below:

  • Create an instance of the SignApi
  • Create an instance of the FileInfo
  • Set the PDF file path
  • Create an instance of the SignDigitalOptions
  • Set SignatureType to Digital
  • Set the ImageFilePath and CertificateFilePath
  • Provide the password
  • Create an instance of the SignSettings
  • Assign the SignDigitalOptions and SaveOptions to the SignSettings
  • Create the CreateSignaturesRequest
  • Get results by calling the SignApi.createSignatures() method

The following code example shows how to sign a PDF document with digital signatures using a REST API in Node.js.

Sign PDF Documents with Digital Signatures using Node.js

Sign PDF Documents with Digital Signatures using Node.js

Verify Digital Signatures using a REST API in Node.js

You can easily verify the digital signatures programmatically by following the steps given below:

  • Create an instance of the SignApi
  • Create an instance of the FileInfo
  • Set the DOCX file path
  • Create an instance of the_VerifyDigitalOptions_
  • Set SignatureType to Digital
  • Create an instance of the VerifySettings
  • Assign the VerifyDigitalOptions and FileInfo to the VerifySettings
  • Create the VerifySignaturesRequest
  • Get results by calling the SignApi.verifySignatures() method
  • Show the results

The following code example shows how to verify the digital signatures using a REST API in Node.js.

Verify Digital Signatures using a REST API in Node.js

Verify Digital Signatures using a REST API in Node.js

Try Online

Please try the following free online documents signature tool, which is developed using the above API. https://products.groupdocs.app/signature/

Conclusion

In this article, you have learned how to sign Word documents with digital signatures on the cloud. You have also learned how to sign PDF documents with digital signatures using a REST API in Node.js. Moreover, you have learned how to programmatically upload a Word file on the cloud and then download the signed file from the cloud. You can learn more about GroupDocs.Signature Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also