Stop writing fetch wrappers by hand. Use @hey-api/openapi-ts to generate a fully typed TypeScript client from the live OpenAPI 3.1 spec — with autocomplete.
If you're integrating unLocked CRM from a TypeScript codebase, the worst thing you can do is hand-roll fetch calls. The OpenAPI 3.1 spec lets you generate a fully typed SDK in seconds.
Install the Generator
npm install -D @hey-api/openapi-tsAdd a Generation Script
In package.json:
"scripts": {
"gen:api": "openapi-ts -i https://unlockedcrm.ai/openapi.json -o src/lib/unlocked -c @hey-api/client-fetch"
}Run It
npm run gen:apiYou now have src/lib/unlocked/ with typed services, schemas, and a configured client. Every endpoint is a function. Every response is a typed object. Every parameter autocompletes.
Use It
import { client, getContacts, createContact } from "@/lib/unlocked";
client.setConfig({
baseUrl: "https://api.unlockedcrm.ai",
headers: { "x-api-key": process.env.UNLOCKED_API_KEY! },
});
const { data, error } = await getContacts({ query: { limit: 50 } });Re-Generate on Every Deploy
Wire npm run gen:api into your CI pipeline so the SDK never drifts from the production API. New endpoints, new fields, and breaking changes show up as TypeScript errors before they hit production.
Other generators worth considering: Stainless (multi-language), Speakeasy (idiomatic SDKs with retries built in), and Fern (docs + SDK in one).