PrismDraft SDK
@prism-draft/sdk is a typed TypeScript client for the PrismDraft API. It calls the API with a workspace API key, turns every failed answer into an error you can catch, retries safe reads, and verifies webhook signatures. It is generated from the API's OpenAPI document, so its types follow the API.
Install
npm install @prism-draft/sdk
The package is ESM only. It needs Node 20 or later, or Bun. It uses the global fetch and Web Crypto and imports nothing from node: or bun:, so another runtime that has both should work too. A custom fetch you pass in must honour the request's signal, which timeouts and cancellation rely on.
First call
Create a key in the web app (Settings, API keys tab) and read your workspace id from the address of the web app: it is the id after /w/. Authentication covers both.
import { PrismDraft } from "@prism-draft/sdk";
const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });
const { articles, total } = await pd.articles.list({ workspaceId, status: "PUBLISHED" });
console.log(`${articles.length} of ${total} published articles`);
The examples in these guides assume pd and these ids are in scope: workspaceId, projectId, articleId, categoryId and sourceId.
Where to go next
| Page | What it covers |
|---|---|
| Authentication | API keys, roles, the workspace id, expiry and rotation. |
| Conventions | How methods, inputs, outputs, pagination and pd.raw work. |
| Errors | PrismDraftError, every error code, and how to handle them. |
| Retries and timeouts | What is retried, what is not, and how to bound a call. |
| Uploads | The two operations that take a file. |
| Webhooks | Registering an endpoint, verifying a delivery, and every event. |
| Versioning | What may change between versions. |
| Recipes | Publish an imported article, plan a month of articles, sync a site from webhooks, paginate, bulk-update categories. |
| API reference | Every method, with its input, its output and the permission it needs. |
The reference pages are one per resource: articles, categories, projects, webhooks and the rest.