Skip to content
DocsSDKAuthentication & API keys

Authentication & API keys

Updated Jul 2026·1 min

Every request authenticates with an API key created in your workspace settings. Keys are prefixed medal_ and scoped to a single workspace.

The API Keys tab in Personal Settings, with one workspace key and the Create API Key button.The API Keys tab in Personal Settings, with one workspace key and the Create API Key button.

new Medal(token, options?)

Pass the API key; options cover baseUrl, timeout, and workspaceId for multi-workspace tokens.

ts
import { Medal } from '@medalsocial/sdk';

const medal = new Medal(process.env.MEDAL_API_KEY as string, {
  timeout: 15_000,
});

Idempotency keys

Idempotency key sent as the Idempotency-Key header. Retries with the same key return the original result instead of repeating the operation. Required by some endpoints for capability-scoped tokens (e.g. helpdesk replies, webhook creation).

ts
await medal.webhooks.create(
  { name: 'CRM sync', url: 'https://example.com/hooks', event_types: ['contact.created'] },
  { idempotencyKey: 'crm-sync-setup-1' }
);

Capability confirmations

Capability confirmation token sent as the X-Capability-Confirmation header. Required alongside idempotencyKey when a token granted a capability-style scope directly (e.g. helpdesk.webhook.manage) executes a confirmable write route. API keys with legacy scopes do not need it.

medal.workspaces.list()

List workspaces accessible to the current API key or OAuth token.

ts
list(): Promise<ApiResponse<Workspace[]>>
Added in v1.0.0