Skip to content

Build and test

Generate a Client

Generate a typed SignatureAPI client in TypeScript from the OpenAPI specification with openapi-typescript and openapi-fetch, using pinned versions.

SignatureAPI has no official SDK. The API is plain HTTP and JSON, and the OpenAPI specification describes every endpoint, so you can generate types and a typed client from it. This guide uses openapi-typescript for the types and its companion openapi-fetch for the requests.

The versions below are pinned and were run against the current specification. Pin them in your project too, and upgrade on purpose.

Install the Tools

You need Node.js 24 or later.

Terminal
npm install openapi-fetch@0.17.0
npm install --save-dev openapi-typescript@7.13.0 typescript@6.0.3 @types/node@24

Generate the Types

Terminal
npx openapi-typescript https://spec.signatureapi.com/openapi.yaml -o signatureapi.d.ts
✨ openapi-typescript 7.13.0
🚀 https://spec.signatureapi.com/openapi.yaml → signatureapi.d.ts

The output is one declaration file with a paths type for every endpoint and a components type for every schema. It has no runtime code. Commit it, and run the command again when you want new API features.

Make a Request

Create the client with the base URL and your API key, then call endpoints by their path. The paths in the specification start after /v1, so the base URL ends with /v1.

list.ts
import createClient from "openapi-fetch";
import type { paths } from "./signatureapi";

const client = createClient<paths>({
  baseUrl: "https://api.signatureapi.com/v1",
  headers: { "X-API-Key": process.env.SIGNATUREAPI_KEY },
});

const { data, error } = await client.GET("/envelopes", {
  params: { query: { status: "completed", limit: 5 } },
});
if (error) throw new Error(`${error.status} ${error.title}`);

for (const envelope of data.data ?? []) {
  console.log(envelope.id, envelope.title);
}

TypeScript now checks the path, the query parameters, the request body and the response. A typo in status, or a missing required field in a POST body, fails at compile time. When the API answers with an error, error holds the problem details body.

The type-only import needs no file extension when moduleResolution is bundler:

tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "target": "es2022",
    "module": "esnext",
    "moduleResolution": "bundler",
    "types": ["node"],
    "noEmit": true
  }
}

Check the types with npx tsc -p ., and run it with node list.ts while SIGNATUREAPI_KEY holds your API key. Node.js 24 runs TypeScript files directly.

Keep It Up to Date

The specification always matches the deployed API. New fields and endpoints appear there first, so regenerate signatureapi.d.ts when you need them, and let the compiler show what changed.

For webhooks, the specification describes each event payload, but the client does not verify deliveries. Use Verify webhook signatures for that.