Atomside docsThis page as Markdown

The TypeScript SDK

@atomside/sdk has one typed method per operation, made from the same definitions as the REST API, the MCP tools and the CLI. It has no dependencies, runs on Node 22 or later (and anywhere with fetch), and lives at app/packages/sdk. It is not on npm yet, and our repository is private: until it is published you can use it only from a copy of the repository that we have given you (ask at [email protected]).

import { createClient } from '@atomside/sdk';

const atomside = createClient(); // reads ATOMSIDE_API_KEY
const account = await atomside.getAccount();
if (account.ok) console.log(account.data.summary);
else console.log(account.refusal.say);

Methods

The method is the operation's name in camelCase: quote_letter is atomside.quoteLetter(input). Its input and output are typed from the operation's schemas, and its refusal codes are a union of the codes that operation can give (SendLetterRefusalCode, say), so a code it cannot give is a type error.

const quote = await atomside.quoteLetter({
  to: { name: 'Ms A. Sample', line1: '12 Specimen Road', postcode: 'TEST 01' },
  pages: [{ text: 'Dear Ms Sample,\n\nYour rent stays the same.', format: 'markdown' }],
});
if (!quote.ok) throw new Error(quote.refusal.say);

const sent = await atomside.sendLetter(
  { quote: quote.data.quote },
  { idempotencyKey: 'rent-review-2026-ms-sample' },
);
if (sent.ok) console.log(sent.data.status);
else if (sent.refusal.answer !== 'no') console.log(sent.refusal.details.show_to_person);
else console.log(sent.refusal.say);

Customers

If your software sends letters for customers of its own, the SDK also has the customer methods: createCustomer, getCustomer, listCustomers, updateCustomer, setCustomerLimits, pauseCustomer, resumeCustomer, requestCustomerSender, confirmCustomerSender, resendCustomerSenderCode, getCustomerUsage, createApprovalLink and closeCustomer. They need a key with the Manage customers scope, which in live mode cannot also send letters, so use a second client with that key. They are not MCP tools. See Sending for your customers.

const accounts = createClient({ apiKey: process.env.ATOMSIDE_MANAGE_KEY });
const customer = await accounts.createCustomer(
  {
    ref: 'cust_4471',
    name: 'Acme Lettings',
    relationship: 'own_letters',
    sender: {
      name: 'Acme Lettings Ltd',
      line1: 'Flat 1',
      line2: '2 Example Street',
      town: 'Sampleford',
      postcode: 'XX2 2XX',
    },
  },
  { idempotencyKey: 'add-cust_4471' },
);
if (customer.ok) console.log(customer.data.state); // waiting_on_sender

Answers and refusals

Every method resolves to { ok: true, data, meta } or { ok: false, refusal, meta }. A refusal is an answer, never an exception: it is the same JSON as over REST and MCP, read as Error handling for agents says. Read refusal.answer first: not_yet and yes_later mean a letter exists, so do not send it again.

meta has the HTTP status, apiVersion (the version the API answered in), requestId, replayed (true when an idempotent call got the first answer back), idempotencyKey and attempts.

A call that gets no answer at all throws AtomsideConnectionError, with failure set to network, not_json (a proxy's error page, say) or unexpected_answer. It carries the call's idempotencyKey: repeat an idempotent call with that key and nothing happens twice.

Idempotency and retries

send_letter and start_account take an idempotency key (Idempotency). Pass your own as idempotencyKey, made from what the letter is. Without one, the SDK makes a random key for the call.

The SDK tries a call again by itself, with the same key, at most twice (maxRetries):

It never repeats any other refusal.

Versions

Each call sends Atomside-Version: 2026-11-24, the version the SDK was generated against, so the answers match its types. Set apiVersion on the client or on one call to ask for another, or null to send none and get the version your key is pinned to. See Versioning.

Settings

OptionDefault
apiKeyATOMSIDE_API_KEY
baseUrlATOMSIDE_API_URL, else https://api.atomside.com
apiVersion2026-11-24; null for none
fetchthe global fetch
maxRetries2
maxRetryWaitMs30000
retryDelayMs500, the first wait after a network failure; it doubles

Each method also takes { idempotencyKey, apiVersion, signal } for one call.