TypeScript SDK
The @thecorporation/corp package provides a typed HTTP client, CLI wrapper, and binary manager for the TheCorporation platform. It uses the standard fetch API (Node 20+ or browser) with zero runtime dependencies.
Install
Section titled “Install”npm install @thecorporation/corpPlatform-specific binaries (corp-server, corp-cli) are installed automatically via optional dependencies.
Quick start
Section titled “Quick start”import { CorpClient } from "@thecorporation/corp";
const client = new CorpClient("http://localhost:8000", "corp_...");
// Create a Delaware C-Corpconst entity = await client.entities.create({ legal_name: "Acme Corp", entity_type: "c_corp", jurisdiction: "DE",});
// Advance formationawait client.formation.advance(entity.entity_id);
// List documentsconst docs = await client.formation.listDocuments(entity.entity_id);Subpath exports
Section titled “Subpath exports”| Import | Contents |
|---|---|
@thecorporation/corp | Everything: types, client, server helpers, CLI wrapper |
@thecorporation/corp/client | CorpClient only (browser-safe, uses fetch) |
@thecorporation/corp/server | Binary resolution, startServer(), runCli() |
@thecorporation/corp/cli | Typed Corp CLI wrapper class |
Use @thecorporation/corp/client for browser or edge environments where Node.js APIs are not available.
API domains
Section titled “API domains”CorpClient exposes typed sub-clients for every API domain:
| Sub-client | Key methods |
|---|---|
client.entities | list(), create(), get(), dissolve() |
client.formation | advance(), listDocuments(), signDocument(), confirmFiling(), confirmEin() |
client.equity | getCapTable(), createInstrument(), createGrant(), issueSafe(), convertSafe(), createHolder(), createTransfer(), executeTransfer(), createPosition(), createRound(), createVestingSchedule() |
client.governance | createBody(), createSeat(), createMeeting(), castVote(), writtenConsent() |
client.treasury | createInvoice(), createPayment(), createPayrollRun(), createBankAccount() |
client.contacts | list(), create(), get(), update(), deactivate() |
client.agents | list(), create(), pause(), resume(), delete() |
client.workItems | list(), create(), claim(), complete(), cancel() |
client.admin | listApiKeys(), createApiKey(), revokeApiKey() |
Error handling
Section titled “Error handling”All methods throw CorpApiError on non-OK responses:
import { CorpClient, CorpApiError } from "@thecorporation/corp";
try { await client.entities.get("nonexistent");} catch (err) { if (err instanceof CorpApiError) { console.log(err.status); // 404 console.log(err.path); // /v1/entities/nonexistent console.log(err.body); // error message from server }}Server management
Section titled “Server management”Start a local corp-server instance programmatically:
import { startServerAndWait } from "@thecorporation/corp/server";
const server = await startServerAndWait({ dataDir: "./corp-data", port: 8000,});
// Use the server...server.kill();CLI wrapper
Section titled “CLI wrapper”The Corp class wraps the corp binary with typed methods:
import { Corp } from "@thecorporation/corp/cli";
const corp = new Corp({ dataDir: "./corp-data" });const entity = await corp.form.create("Acme Corp", "c_corp", "DE");await corp.form.advance(entity.entity_id);