Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getmaito.com/llms.txt

Use this file to discover all available pages before exploring further.

TypeScript SDK

The SDK in packages/sdk is the preferred TypeScript client for browser, server, CLI, and automation code that talks to the REST API.

Create A Client

import { createApiClient } from "@repo/sdk";

const maito = createApiClient({
  baseUrl: "https://api.getmaito.com",
  authToken: () => process.env.MAITO_API_KEY,
});
authToken can be a string, null, undefined, or an async function returning a token.

Example: List Drafts

const drafts = await maito.drafts.list({ limit: 20 });

Example: Upsert A Document

await maito.documents.upsertByPath({
  path: "profiles/founder.md",
  role: "profile",
  documentType: "note",
  status: "active",
  title: "Founder profile",
  bodyMarkdown: "Public bio and positioning notes.",
});

Example: Create A Newsletter Issue

const issue = await maito.newsletter.issues.create({
  subject: "Launch notes",
  previewText: "What changed this week",
  contentHtml: "<p>Hello subscribers.</p>",
});

Request Behavior

The SDK:
  • Normalizes baseUrl
  • Adds Authorization: Bearer <token> when a token is available
  • Sends JSON bodies with content-type: application/json
  • Parses API success and error envelopes with shared contracts
  • Throws on API errors, invalid response shapes, and failed requests

Contract Source

Request and response schemas live in packages/contracts. Keep new public API shape changes in contracts first, then update backend routes, SDK methods, and docs together.