Skip to content

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.

Terminal window
npm install @thecorporation/corp

Platform-specific binaries (corp-server, corp-cli) are installed automatically via optional dependencies.

import { CorpClient } from "@thecorporation/corp";
const client = new CorpClient("http://localhost:8000", "corp_...");
// Create a Delaware C-Corp
const entity = await client.entities.create({
legal_name: "Acme Corp",
entity_type: "c_corp",
jurisdiction: "DE",
});
// Advance formation
await client.formation.advance(entity.entity_id);
// List documents
const docs = await client.formation.listDocuments(entity.entity_id);
ImportContents
@thecorporation/corpEverything: types, client, server helpers, CLI wrapper
@thecorporation/corp/clientCorpClient only (browser-safe, uses fetch)
@thecorporation/corp/serverBinary resolution, startServer(), runCli()
@thecorporation/corp/cliTyped Corp CLI wrapper class

Use @thecorporation/corp/client for browser or edge environments where Node.js APIs are not available.

CorpClient exposes typed sub-clients for every API domain:

Sub-clientKey methods
client.entitieslist(), create(), get(), dissolve()
client.formationadvance(), listDocuments(), signDocument(), confirmFiling(), confirmEin()
client.equitygetCapTable(), createInstrument(), createGrant(), issueSafe(), convertSafe(), createHolder(), createTransfer(), executeTransfer(), createPosition(), createRound(), createVestingSchedule()
client.governancecreateBody(), createSeat(), createMeeting(), castVote(), writtenConsent()
client.treasurycreateInvoice(), createPayment(), createPayrollRun(), createBankAccount()
client.contactslist(), create(), get(), update(), deactivate()
client.agentslist(), create(), pause(), resume(), delete()
client.workItemslist(), create(), claim(), complete(), cancel()
client.adminlistApiKeys(), createApiKey(), revokeApiKey()

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
}
}

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();

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);