inklok-sdk-node
v2.1.18
Published
Official Node.js SDK for the Inklok API.
Maintainers
Readme
inklok-sdk-node
Official Node.js SDK for the Inklok API.
The SDK is a thin, typed client over the Inklok public API. It handles base URL normalization, bearer authentication, generated TypeScript types, pagination normalization, signer-session helpers, and encrypted document helpers.
For endpoint schemas, request and response contracts, status codes, and HTTP-level behavior, use the Inklok API reference:
https://docs.inklok.com/docs/api-reference
Installation
npm install inklok-sdk-nodeNode.js 18 or newer is required.
Quickstart
import { InklokClient } from "inklok-sdk-node";
const client = new InklokClient({
baseUrl: "https://api.inklok.com",
accessToken: process.env.INKLOK_ACCESS_TOKEN!,
});
const orgId = process.env.INKLOK_ORG_ID!;
const myOrgs = await client.listMeOrgs({});
const documents = await client.listDocumentsV1({
orgId,
});
console.log({ myOrgs, documents });Authentication
Pass a bearer credential with accessToken.
Supported credentials include:
- user access tokens for user-driven API calls
- Inklok API keys for integration calls
For user-token calls, org-scoped methods also require orgId, which the SDK sends as X-Inklok-Org-Id. For API-key calls, org tenancy is derived from the key and the SDK omits the org header.
Use sandbox API keys while developing and testing integrations. Sandbox keys can access sandbox resources without contacting real recipients.
API Base URL
The production Inklok API endpoint is:
https://api.inklok.comSDK clients and integrations should use this as the production baseUrl.
API Contract Types
The SDK generates TypeScript API contract types from the published OpenAPI specification package:
@inklok/api-specDo not hand-edit generated types. Update the API spec package dependency and regenerate SDK types when the API contract changes.
Common Usage
Organization Bootstrap
Use listMeOrgs or getBootstrap after login to discover the current user's organization memberships and bootstrap application state.
const bootstrap = await client.getBootstrap({});Documents
Use the low-level document methods when you already have encrypted bytes. Use client.documents.upload when you want the SDK to perform client-side encryption before upload.
const uploaded = await client.documents.upload({
orgId,
fileBuffer,
metadata: { filename: "agreement.pdf" },
});Templates And Agreements
Create a template from a document, publish it, then create agreements from the published template. Use an idempotencyKey when creating durable agreement state that may be retried.
const template = await client.createTemplateV1({
orgId,
documentId,
body: { name: "Standard agreement" },
});
const published = await client.publishTemplateV1({
orgId,
workflowId: template.id,
});
const agreement = await client.createAgreementV1({
orgId,
workflowId: published.id,
idempotencyKey: "agreement-request-123",
body: {
participants: [{ roleId: "signer", email: "[email protected]" }],
},
});For retry rules, see Retry And Idempotency.
Signer Sessions
For magic-link signing, exchange a link code for an in-memory signer session and bind it to signer-facing helpers.
import { SignerSessionManager } from "inklok-sdk-node";
const session = new SignerSessionManager(
"https://api.inklok.com",
magicLinkCode,
);
const signer = client.withSignerSession(session);
const signingAgreement = await signer.signing.getSigningAgreement();Examples
Runnable examples live in examples:
Build the package first, then run an example with environment variables:
npm install
npm run build
INKLOK_API_BASE="https://api.inklok.com" \
INKLOK_ACCESS_TOKEN="token-or-api-key" \
INKLOK_ORG_ID="org-id" \
node examples/basic-client.mjsDevelopment
npm install
npm run build
npm testTypes are regenerated from @inklok/api-spec before build. Run npm run codegen to regenerate only src/types.d.ts.
Documentation
- API Reference: https://docs.inklok.com/docs/api-reference
- SDK docs index
- Retry and idempotency
- Local development
- Release and versioning
- Architecture notes
