Sign documents from your code
Send a document for signature from TypeScript
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 types ship inside the package: SendRequest describes what you send and the answer is typed too, so a wrong field name fails in your editor and not at 2 a.m. The program runs as it stands on Node 22 and newer with --experimental-strip-types; elsewhere compile it with tsc as usual.
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.ts 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: JavaScript · Python · Ruby · Java

Types come with the package
Install the same npm package as for JavaScript; the type declarations ship inside it, so there is no separate types package to add. Parties, templates, documents and webhook events are typed, which means the editor tells you that a party needs a seat and an email before the program ever runs. Compile with tsc or run it directly with a loader such as tsx.
Configuration in the program
Read DOCUSTAY_KEY and TEMPLATE_ID from process.env and fail early if either is missing; the compiler cannot know they are set. Keep the key out of source control, and use a test key while you are building: a test key can only create TEST documents that email you, so a mistake in a loop costs nothing and reaches nobody.
Narrowing the answer
The state of a document is a union of strings, so a switch over it is checked for completeness: add a case for declined and expired, or the compiler points at the gap. The same goes for the webhook event type. That is the main reason to prefer this page to the JavaScript one when you write more than a few lines.
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.
Do I need a tsconfig?
Only the usual one for your project. The package works with module resolution set to node16, nodenext or bundler.
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.