Appearance
TypeScript SDK
A fully typed client, generated from the committed OpenAPI contract, so it never drifts from the API. The runtime is openapi-fetch, which infers request and response types per operation.
Install
bash
npm install @opaline/sdkUse
ts
import { createOpalineClient } from '@opaline/sdk'
const opaline = createOpalineClient({
baseUrl: 'https://api.opaline.dev',
apiKey: 'opl_live_…', // or opl_test_ / opl_admin_
})
const { data, error } = await opaline.POST('/v1/decide', {
params: { header: { 'Idempotency-Key': crypto.randomUUID() } },
body: {
pack: 'acme.bill.validity',
version: '1.2.0',
facts: { vat_rate: '0.1' },
context: {},
},
})
if (error) {
// `error` is the typed RFC 9457 Problem (code, title, detail, …).
console.error(error.code, error.detail)
} else {
console.log(data) // typed decision
}The path, params, body, and response are all checked at compile time. An invalid path or a missing required field is a type error.
Authentication
apiKey is sent as Authorization: Bearer <key>:
opl_live_/opl_test_: tenant data plane (decide, simulate, packs, trail).opl_admin_: your tenant master key, for/v1/keys(mint and revoke your own data-plane keys).- Omit for unauthenticated endpoints (
/healthz,/metrics,/v1/schemas/pack).
How it stays in sync
src/schema.ts is generated from the OpenAPI contract by openapi-typescript; CI regenerates and diffs it, so a change to the API can never silently diverge from the SDK types.