Introduction to Digital Signatures
Digital signatures are a type of electronic signature that ensures the authenticity and integrity of a digital message or document. A digital signature is created using a Public Key Infrastructure (PKI) to encrypt data using a private key. This makes it highly secure and legally binding.
Popular Digital Signature APIs
1. DocuSign API
DocuSign is a widely-used digital signature platform that provides an easy-to-implement API for integrating digital signing capabilities into your application. Below is an example of how to use the DocuSign API to create an envelope.
import docusign_esign as docusign from docusign_esign.rest import ApiException def create_envelope(): api_client = docusign.ApiClient() api_client.host = 'https://demo.docusign.net/restapi' api_client.set_default_header('Authorization', 'Bearer YOUR_ACCESS_TOKEN') envelope_definition = docusign.EnvelopeDefinition( email_subject="Please sign this document", documents=[ docusign.Document( document_base64="BASE64_STRING", name="Sample Document", file_extension="pdf", document_id=1 ) ], recipients=docusign.Recipients( signers=[ docusign.Signer( email="signer@example.com", name="John Doe", recipient_id="1", tabs=docusign.Tabs( sign_here_tabs=[ docusign.SignHere( document_id="1", page_number="1", recipient_id="1", tab_label="SignHereTab", x_position="200", y_position="300" ) ] ) ) ] ), status="sent" ) envelopes_api = docusign.EnvelopesApi(api_client) try: envelope_summary = envelopes_api.create_envelope('YOUR_ACCOUNT_ID', envelope_definition=envelope_definition) print("Envelope has been sent. Envelope ID: {}".format(envelope_summary.envelope_id)) except ApiException as e: print("Exception when calling EnvelopesApi->create_envelope: %s" % e)
2. HelloSign API
HelloSign, now part of Dropbox, provides a user-friendly API for electronic signatures. Here is an example of creating a signature request using HelloSign API.
import requests def send_signature_request(api_key, signer_email, signer_name, file_path): url = "https://api.hellosign.com/v3/signature_request/send" headers = { "Authorization": "Basic " + api_key } data = { "title": "Document Title", "subject": "Please sign this document", "message": "Please review and sign this document at your earliest convenience.", "signers[0][email_address]": signer_email, "signers[0][name]": signer_name, } files = {"file[0]": open(file_path, "rb")} response = requests.post(url, headers=headers, data=data, files=files) if response.status_code == 200: print('Signature request sent successfully.') else: print('Error sending signature request: {}'.format(response.text))
3. Adobe Sign API
Adobe Sign is a part of Adobe’s Document Cloud suite, providing seamless digital signature integrations. Below is an example of using Adobe Sign API to send a document for signing.
import requests def send_for_signing(api_access_token, api_agreement_id, signer_email, signer_name): headers = { 'Authorization': 'Bearer {}'.format(api_access_token), 'Content-Type': 'application/json' } url = 'https://api.na1.adobesign.com/api/rest/v6/agreements/{}'.format(api_agreement_id) data = { "fileInfos": [{"fileId": api_agreement_id}], "name": "Document for Signing", "participantSetsInfo": [ { "memberInfos": [{"email": signer_email}], "order": 1, "role": "SIGNER" } ], "signatureType": "ESIGN", "state": "IN_PROCESS" } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: print('Document sent successfully for signing.') else: print('Error sending document: {}'.format(response.text))
Example Application with API Integrations
Using the APIs mentioned above, we can create a web application that allows users to upload documents and send them for signing. Below is a simplified example using Flask (a Python web framework) to handle the document upload and signature requests.
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/upload', methods=['POST']) def upload_file(): if 'file' not in request.files: return jsonify({'error': 'No file part in the request'}), 400 file = request.files['file'] if file.filename == '': return jsonify({'error': 'No file selected for uploading'}), 400 # Save the file locally file.save('/path/to/save/' + file.filename) # Call your signature API functions here (e.g., DocuSign, HelloSign, Adobe Sign) # For simplicity, let's say we call send_signature_request() success = send_signature_request(api_key='your-api-key', signer_email='signer@example.com', signer_name='John Doe', file_path='/path/to/save/' + file.filename) if success: return jsonify({'message': 'File successfully uploaded and signature request sent'}), 200 else: return jsonify({'error': 'Failed to send signature request'}), 500 if __name__ == '__main__': app.run(debug=True)
In this example, we have a Flask web application with a single route ‘/upload’ that handles file uploads and sends the file for signing using one of the digital signature APIs.
Hash: cfebcdb74904738632c70439695a37146f315e9909aab221780b9577179b837c