Skip to content
// FLEET
us-west-1GB300 · liquid
eu-central-1B300 · liquid
apac-sg-1GB200 · NVL72
me-uae-1VR200 · Rubin
// SDK REFERENCE

SDK reference

The Segal TypeScript SDK is a thin, fully-typed client over the REST API. Its surface is generated from the same OpenAPI 3.1.0 document as the API reference, so every method maps one-to-one to an endpoint and never drifts.

Roadmap package

The SDK shape below is generated from the spec to show the intended ergonomics. The published package and version will land here once released.

Install

bash
npm install @segal/sdk

Initialize

Construct the client with a scoped sk_segal_ API key. Read it from the environment — never hard-code a key.

ts
import { Segal } from "@segal/sdk";

const segal = new Segal({ apiKey: process.env.SEGAL_API_KEY });

Errors

Failed calls throw a SegalError carrying the same envelope as the REST API — type, code, message, and request_id. See Errors.

ts
import { Segal, SegalError } from "@segal/sdk";

try {
  await segal.domains.registerDomain({ name: "acme.dev" });
} catch (err) {
  if (err instanceof SegalError) {
    console.error(err.code, err.requestId);
  }
}

Service clients

Each service is a namespaced client. Methods are named for their operationId and take a single typed argument object.

segal.domains

API →
  • segal.domains.listDomains(options?)

    GET /api/v1/domains List domains

  • segal.domains.registerDomain({ … })

    POST /api/v1/domains Register a domain

segal.dns

API →
  • segal.dns.listZones()

    GET /api/v1/dns List DNS zones

  • segal.dns.createZone({ … })

    POST /api/v1/dns Create a DNS zone

segal.sites

API →
  • segal.sites.listSites()

    GET /api/v1/sites List sites

  • segal.sites.createSite({ … })

    POST /api/v1/sites Create a site

segal.databases

API →
  • segal.databases.listDatabases()

    GET /api/v1/databases List databases

  • segal.databases.createDatabase({ … })

    POST /api/v1/databases Create a database

segal.vpn

API →
  • segal.vpn.listVpnNetworks()

    GET /api/v1/vpn List VPN networks

  • segal.vpn.createVpnNetwork({ … })

    POST /api/v1/vpn Create a VPN network