Skip to content

TypeScript SDK

Terminal window
npm install @sortdo/sdk
import { ApprovalRequired, SortError, createSort } from '@sortdo/sdk'
const sort = createSort({ token: process.env.SORT_API_KEY! })
const { items: teams } = await sort.teams.list({})
try {
await sort.teams.add_members({ teamId: teams[0].id, memberIds: ['…'] })
} catch (error) {
if (error instanceof ApprovalRequired) console.log('Ask the person to approve:', error.approval.url)
else if (error instanceof SortError) console.log(error.code, error.message)
else throw error
}

Each operation is a method of its area, with the input and output types of the reference. sort.call('teams.list', {}) calls one by name. Pass { idempotencyKey } as the second argument of a write to make a retry safe.

verifyWebhook(body, signatureHeader, secret) checks a webhook request: see Events and webhooks. The package uses the standard fetch and Web Crypto, so it runs in Node.js 20 or later, Bun, Deno and edge runtimes.

For other languages, generate a client from /v1/openapi.json.