Esignatures.docusign
A Library for interacting with DocuSign eSignature API which optionally provides Integrant initialization keys for Duct framework.
Install / Use
/learn @gethop-dev/Esignatures.docusignREADME
esignatures.docusign
A Library for interacting with the Docusign eSignature API which optionally provides Integrant initialization keys for the Duct framework.
Table of Contents
Installation
Usage
Configuration
To use this library add the following key to your configuration:
:dev.gethop.esignatures/docusign
This key expects a configuration map with two mandatory keys These are the mandatory keys:
:auth-config: A map containing DocuSign authentication details. The map contains the following mandatory keys::integration-key: Your DocuSign application's integration key.:user-id: DocuSign account's UserId.:auth-service-uri: DocuSign authentication server URL.:private-key: DocuSign application's private RSA key.
:base-url: The base URL for DocuSign API. The/restapiis already considered so no need to include it.:account-id: DocuSign account's ID.
These are the optional keys:
:timeout: Timeout value (in milli-seconds) for an connection attempt with DocuSign API.:max-retries: If the connection attempt fails, how many retries we want to attempt before giving up.:backoff-ms: This is a vector in the form [initial-delay-ms max-delay-ms multiplier] to control the delay between each retry. The delay for nth retry will be (max (* initial-delay-ms n multiplier) max-delay-ms). If multiplier is not specified (or if it is nil), a multiplier of 2 is used. All times are in milli-seconds.
Key initialization returns a DocuSign record that can be used to perform the DocuSign operations described below.
Configuration example
Basic configuration:
:dev.gethop.esignatures/docusign
{:auth-config {:integration-key "5ff3dade-dd8e-4da4-a29e-f0463120a57f"
:user-id "3e2a655b-7d95-447b-ba26-e5b6c896fe66"
:auth-service-uri "https://account-d.docusign.com"
:private-key "DocuSign Application's Private RSA Key"}
:base-url "https://demo.docusign.net"
:account-id "ea1b567f-dd03-41bf-a916-64ec174c8bb6"}
Configuration with custom request retry policy:
:dev.gethop.esignatures/docusign
{:auth-config {:integration-key "5ff3dade-dd8e-4da4-a29e-f0463120a57f"
:user-id "3e2a655b-7d95-447b-ba26-e5b6c896fe66"
:auth-service-uri "https://account-d.docusign.com"
:private-key "DocuSign Application's Private RSA Key"}
:base-url "https://demo.docusign.net"
:account-id "ea1b567f-dd03-41bf-a916-64ec174c8bb6"
:timeout 3000
:max-retries 5
:backoff-ms [10 500]}
Obtaining a DocuSign record
Using Duct
If you are using the library as part of a Duct-based project, adding any of the previous configurations to your config.edn file will perform all the steps necessary to initialize the key and return a DocuSign record for the associated configuration. In order to show a few interactive usages of the library, we will do all the steps manually in the REPL.
First we require the relevant namespaces:
user> (require '[integrant.core :as ig])
nil
user>
Next we create the configuration var holding the DocuSign integration configuration details:
user> (def config :dev.gethop.esignatures/docusign
{:auth-config {:integration-key "5ff3dade-dd8e-4da4-a29e-f0463120a57f"
:user-id "3e2a655b-7d95-447b-ba26-e5b6c896fe66"
:auth-service-uri "https://account-d.docusign.com"
:private-key "DocuSign Application's Private RSA Key"}
:base-url "https://demo.docusign.net"
:account-id "ea1b567f-dd03-41bf-a916-64ec174c8bb6"})
#'user/config
user>
Now that we have all pieces in place, we can initialize the :dev.gethop.esignature/docusign Integrant key to get a DocuSign record. As we are doing all this from the REPL, we have to manually require dev.gethop.esignature.docusign namespace, where the init-key multimethod for that key is defined (this is not needed when Duct takes care of initializing the key as part of the application start up):
user> (require '[dev.gethop.esignatures.docusign :as docusign])
nil
user>
And we finally initialize the key with the configuration defined above, to get our DocuSign record:
user> (def ds-record (ig/init-key :dev.gethop.esignatures/docusign config))
#'user/ds-record
user> ds-record
#dev.gethop.esignatures.docusign.DocuSign{:auth-config {:integration-key "5ff3dade-dd8e-4da4-a29e-f0463120a57f"
:user-id "3e2a655b-7d95-447b-ba26-e5b6c896fe66"
:auth-service-uri "https://account-d.docusign.com"
:private-key "DocuSign Application's Private RSA Key"}
:base-url "https://demo.docusign.net"
:account-id "ea1b567f-dd03-41bf-a916-64ec174c8bb6"}
user>
Not using Duct
user> (require '[dev.gethop.esignatures.docusign :as docusign])
user> (docusign/init-record {:auth-config {:integration-key "5ff3dade-dd8e-4da4-a29e-f0463120a57f"
:user-id "3e2a655b-7d95-447b-ba26-e5b6c896fe66"
:auth-service-uri "https://account-d.docusign.com"
:private-key "DocuSign Application's Private RSA Key"}
:base-url "https://demo.docusign.net"
:account-id "ea1b567f-dd03-41bf-a916-64ec174c8bb6"})
#dev.gethop.esignatures.docusign.DocuSign{:auth-config {:integration-key "5ff3dade-dd8e-4da4-a29e-f0463120a57f"
:user-id "3e2a655b-7d95-447b-ba26-e5b6c896fe66"
:auth-service-uri "https://account-d.docusign.com"
:private-key "DocuSign Application's Private RSA Key"}
:base-url "https://demo.docusign.net"
:account-id "ea1b567f-dd03-41bf-a916-64ec174c8bb6"}
Now that we have our DocuSign record, we are ready to use the methods defined by the protocols defined in dev.gethop.esignatures.core namespace.
Creating an envelope
The envelope has two mandatory sets of entities, Documents and Signers.
:documents: A vector ofDocumententity, each document have the following mandatory keys::name: The name of the document.:file-extension: The extension of the document. Refer to the DocuSign specification to see the supported file formats.:stream: The document file as aninput-stream.
:signers: A vector ofSignerentity, each signer have the following mandatory keys::id: theclientUserIdof the recipient.:email: the email of the signer.:name: The name of the signer.
Beware that these are only the minimal set of parameters needed to create an envelope but more parameters can be especified that are supported by the DocuSign Envelope API specification. The create-envelope is multi arity method and you can provide an additional parameter called opts which is a map with optional parameters.
An example of creating a sample envelope:
user> (create-envelope ds-record {:documents [{:name "test"
:file-extension "pdf"
:stream test-file}]
:signers [{:id "1"
:email "lucas.sousa@magnet.coop"
:name "Lucas Sousa"}]})
{:success? true, :id "98a4c44b-55e3-4694-8ebd-a438060471ba"}
Delete an Envelope
Although the method is called 'delete' for consistency across
different implementations of the esignature protocol, for this
specific implementation it won't really delete the documents, but only mark
them as voided. The additional opts can be used to specify the voidedReason.
this: The DocuSign record.:envelope-id: The envelope ID.
The delete-envelope is multi arity method and you can provide an
additional parameter called opts which is a map with optional
parameters.
An example of deleting an envelope:
user> (delete-envelope ds-record "98a4c44b-55e3-4694-8ebd-a438060471ba")
{:success? true}
Get Envelope Signing URL
To get an envelope signing URL the following parameters are mandatory:
envelope-id: The envelope ID.signer:
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
