Sign documents from your code
Send a document for signature from JavaScript
Make a test key, make a template, and run this. A test key sends nothing real and bills nothing.
Install
Add the Docustay SDK:
npm install @docustay/sdkThe package has no dependencies and needs Node 18 or newer. It makes one Idempotency-Key for each call and reuses it on every retry, so a network retry never sends the document twice. It is an ES module, so use import, or a .mjs file.
Send
This sends the template to one person. It reads your key and template id from the environment, so the key never sits in the file.
send.mjs Then
The answer holds the document's id and its state. Ask for it later with the same key, or get a signed webhook when it is signed. The quick start shows the rest.
Other languages: TypeScript · Python · Ruby · Java

What you need installed
Node 18 or newer, and the Docustay package from npm. Node 18 has fetch built in, so the package adds only the typed helpers and the webhook check. The program is an ES module: save it as send.mjs, or set the package type to module, and run it with node. The key and the template id come from DOCUSTAY_KEY and TEMPLATE_ID in the shell, so neither is ever written into the file.
How the send behaves
The call returns a promise that resolves to the new document, with its id and its state. A repeat with the same idempotency key resolves to the same document instead of making a second one, so a retry after a dropped connection cannot double-send. If the key is wrong or lacks the permission, the promise rejects with an error whose message names the request id; paste that id into the API log to find the call.
Reading the result
Await getDocument with the id and read its state: sent, partially signed, executed, declined, expired or voided. In a server you will rarely poll. Register a webhook, verify each delivery with the package's verifyWebhook, and react to documents.document.executed by downloading the sealed PDF.
Questions people ask
Does a test key send real email?
No. A test key emails only you, stamps the document TEST and is never counted against your plan.
Can I use require instead of import?
Yes. The package ships both module formats, so a CommonJS file can require it.
Where do I see the result?
In Documents in the app, and in the API log under Developers.
Keep reading
Make a test key and try it
Create a workspace, upload a document and send it. No card needed.