@mdedit/sdk
Official JavaScript SDK for mdedit.ai.
This package is designed for authenticated usage: all API access depends on your backend enforcing auth/authz.
Install
npm install @mdedit/sdk
Get an API key
All APIs require authentication. Create an API key here:
Usage
import { createSdkClient } from '@mdedit/sdk';
const client = createSdkClient({
baseUrlV2: 'https://apiv2.mdedit.ai/api',
getAuthHeaders: async () => ({
'x-api-key': process.env.MDEDIT_API_KEY!,
}),
});
const workspaces = await client.workspace.list();
Public links
New agent-facing workflows should request mode: 'live'; a Live link follows later
durable document edits at the same URL. Use mode: 'snapshot' for a frozen artifact.
When updating an existing publication, omit mode to preserve its stored mode.
const publication = await client.publish.publish(workspaceId, articleId, {
mode: 'live',
});
const status = await client.publish.status(workspaceId, articleId);
console.log({
url: status.shortUrl,
mode: status.mode,
sourceVersionId: status.sourceVersionId,
syncStatus: status.syncStatus,
syncError: status.syncError,
});
The SDK exports PublicationMode, PublicationSyncStatus, and
PublicationSourceMetadata for typed integrations. Existing links without stored mode
metadata are legacy Snapshots until explicitly changed.
Error handling
SDK methods throw FetchError for HTTP errors (includes status).
Semver strategy
Current major version is 0 (pre-1.0.0).
0.x minor versions may include breaking changes.
0.x patch versions are reserved for backwards-compatible fixes.
License
See LICENSE.