Docs

App Node SDK

The server-side TypeScript package for native ATM checkout, status reconciliation, notifications and Tickets calls.

Closed beta@atmosphere-money/app-nodeSDK beta: 0.0.0-beta.3ATM API beta: 2026-0671 published lexicons

Compatible with the closed-beta ATM app APIs and versioned ATM event headers. Check atm-api-version on every webhook or XRPC receiver event.

Package status

@atmosphere-money/app-node is ATM's SDK for app backends. It is MIT licensed, needs Node 22 or newer, has no runtime dependencies, and exports ESM with TypeScript declarations. The package license covers this SDK only.

View the package on npmx to review its README, source, changelog, provenance and package signals.

Native test checkoutServer-side onlyPinned native build

Native build and API compatibility

The native checkout helpers (createCheckout, getCheckoutStatus, createAtmCheckoutAttempts and createAtmFileStore) ship in the pinned native build supplied for your integration. Older npm betas may not include them. Webhook and receiver events carry an atm-api-version header; check it, and do not accept unknown future shapes without a compatibility review.

Package@atmosphere-money/app-node
Native buildSupplied for your integration. Keep its integrity hash in your lockfile; the version number alone does not identify it.
API compatibilityATM API beta: 2026-06
Package browserhttps://npmx.dev/package/@atmosphere-money/app-node
Event version signalatm-api-version header on HTTP webhooks and XRPC receiver events.
Breaking changesDocumented in the SDK reference, Versioning and the package changelog.

Install

sh
# For example, a supplied package tarball:
npm install ./atmosphere-money-app-node-<version>.tgz

# Confirm the native helpers are present. This prints "function".
node -e "import('@atmosphere-money/app-node').then((sdk) => console.log(typeof sdk.createAtmCheckoutAttempts))"

Keep the package on your backend. Update it deliberately, and review the changelog before you do.

Initialize

The SDK asks your backend for a fresh service-auth JWT on every app-facing XRPC call and passes the exact lxm and aud to sign. Point the client at your assigned test broker.

ts
import { createAtmAppClient } from "@atmosphere-money/app-node";

export const atm = createAtmAppClient({
  brokerUrl: "https://your-assigned-test-checkout.example",
  serviceAudience: "did:plc:bbbbbbbbbbbbbbbbbbbbbbbb#atmosphere_money_broker",
  // A NEW token per call, signed by your PDS via com.atproto.server.getServiceAuth.
  getServiceAuthToken: ({ lxm, aud }) => mintMyAppServiceAuthJwt({ lxm, aud }),
});

For checkout itself, use createAtmCheckoutAttempts. It uses the same transport, with durable attempts.

Start checkout

Capture a durable attempt before contacting ATM, then send it. recover is safe to repeat: it always replays the original body and key.

ts
import {
  createAtmCheckoutAttempts,
  createAtmFileStore,
  type AtmCheckoutAttempt,
} from "@atmosphere-money/app-node";

const attempts = createAtmCheckoutAttempts({
  appDid: "did:plc:aaaaaaaaaaaaaaaaaaaaaaaa",
  brokerDid: "did:plc:bbbbbbbbbbbbbbbbbbbbbbbb",
  brokerUrl: "https://your-assigned-test-checkout.example",
  store: createAtmFileStore<AtmCheckoutAttempt>("./private-attempts"),
  getServiceAuthToken: ({ lxm, aud }) => mintMyAppServiceAuthJwt({ lxm, aud }),
});

// Illustrative refs: use your seller's exact Product and fixed Price.
const cid = "bafyreigh2akiscaildcwti7d2x3xfyq5gsgq7s6ni5cndflr2nzz4j4y5m";
await attempts.capture("order_123_attempt_1", {
  environment: "test",
  idempotencyKey: "order_123_attempt_1",
  items: [{
    recipient: "did:plc:cccccccccccccccccccccccc",
    listing: { uri: "at://did:plc:cccccccccccccccccccccccc/money.atmosphere.product/digital", cid },
    price: { uri: "at://did:plc:cccccccccccccccccccccccc/money.atmosphere.price/fixed", cid },
    quantity: 1,
    paymentType: "shop",
  }],
  returnUrl: "https://app.example/orders/123/return",
});
const attempt = await attempts.recover("order_123_attempt_1");
export const checkoutUrl = attempt.checkout!.url; // only this goes to the buyer

A backend worker then reconciles the attempt, whether or not the buyer returns:

ts
const result = await attempts.reconcile("order_123_attempt_1");
if (result.action === "fulfil") {
  // completed + fulfil. Insert result.effectKey under a unique constraint and
  // grant the purchase in the SAME database transaction.
}
// "wait": poll again later. "closed": failed, canceled or expired.
// "order": an order owner must confirm first.

Optional webhook receiver

If you opt into HTTP webhooks, verify the exact raw body and ATM headers. Claim a delivery before queuing work, complete it only after a 2xx result, and release failed claims so ATM can redrive them.

ts
import { createNodeWebhookHandler } from "@atmosphere-money/app-node";

export const POST = createNodeWebhookHandler({
  secret: [process.env.ATM_WEBHOOK_SECRET, process.env.ATM_WEBHOOK_PREVIOUS_SECRET]
    .filter((value): value is string => Boolean(value)),
  deliveryStore: {
    claim: claimWebhookDelivery,
    complete: completeWebhookDelivery,
    release: releaseWebhookDelivery,
  },
  onEvent: async (event) => {
    if (event.environment !== "test" || event.apiVersion !== "2026-07")
      return { status: 422, body: { error: "UnexpectedEventBinding" } };
    await enqueueReconciliation(event); // the worker reads canonical status
    return { body: { ok: true } };
  },
});

When you know the expected event type, the typed constructor gives you a narrower event.data shape for parsing or tests. In routes, use a handler with a delivery store.

ts
const paymentEvent = constructTypedAtmWebhookEvent({
  rawBody,
  secret: process.env.ATM_WEBHOOK_SECRET!,
  expectedType: "payment.completed",
  headers: {
    signature: request.headers.get("atm-signature"),
    deliveryId: request.headers.get("atm-delivery-id"),
    apiVersion: request.headers.get("atm-api-version"),
    environment: request.headers.get("atm-environment"),
  },
});

console.log(paymentEvent.data.payment.id);

For route-level integration, use createNodeWebhookHandler, createNextWebhookRoute, createExpressWebhookHandler, createHonoWebhookHandler, or createCloudflareWorkerWebhookHandler. All of them verify the signed raw body and give your code a typed ATM event before it wakes canonical status reconciliation.

Fetch-style helpers stream at most 1 MiB by default before rejecting the request. All webhook verification paths also cap the Atm-Signature header at 8 KiB and accept at most eight v1 rotation signatures. Express apps must apply the same or a smaller limit in their raw-body middleware because it runs before the SDK handler.

Tickets helpers

Tickets use the same package because ticket holds, free limited claims and QR or pass checks all depend on ATM app auth. Tickets follow their own admitted contract; a ticket hold is not native checkout admission.

ts
import { createFreeTicketClaimBody, createTicketHoldBody } from "@atmosphere-money/app-node";

const eventUri = "at://did:plc:organizer/community.lexicon.calendar.event/demo";
const availability = await atm.getTicketAvailability({ environment: "test", eventUri });

const hold = await atm.createTicketHold(createTicketHoldBody({
  environment: "test",
  eventUri,
  buyerDid: "did:plc:buyer",
  buyerAssertionJwt: "short-lived-buyer-assertion",
  items: [{ ticketTypeId: "tier_123", quantity: 2 }],
  returnUrl: "https://app.example/tickets/return",
  cancelUrl: "https://app.example/events/demo",
  idempotencyKey: "hold:event:buyer:tier_123:2",
}));
// Persist hold.statusToken on your server, then redirect to hold.url.

const freeClaim = await atm.claimFreeTicket(createFreeTicketClaimBody({
  environment: "test",
  eventUri,
  buyerDid: "did:plc:buyer",
  buyerAssertionJwt: "short-lived-buyer-assertion",
  customerEmail: "buyer@example.com",
  items: [{ ticketTypeId: "tier_free", quantity: 1 }],
  idempotencyKey: "claim:event:buyer:tier_free",
}));

const verified = await atm.verifyTicket({
  environment: "test",
  ticketToken: "opaque_scan_token",
});
export { availability, freeClaim, hold, verified };

Ticket-specific concepts, diagrams, and scanner flows live on atmosphere.tickets. ATM docs cover the shared payment, app auth, and event surfaces.

Framework examples

Copyable examples so you can start from your own backend style without rewriting the verification logic. Every webhook example queues reconciliation; none grants a purchase from the event alone.

Native integrationdocs/developer/examples/happy-path-app.ts
Next checkout routedocs/developer/examples/next-checkout-route.ts
Next webhook routedocs/developer/examples/next-webhook-route.ts
Next XRPC receiver routedocs/developer/examples/next-xrpc-receiver-route.ts
Express webhook routedocs/developer/examples/express-webhook-route.ts
Fastify webhook routedocs/developer/examples/fastify-webhook-route.ts
Hono webhook routedocs/developer/examples/hono-webhook-route.ts
Cloudflare Worker webhookdocs/developer/examples/cloudflare-worker-webhook.ts
Ticket hold checkoutdocs/developer/examples/ticket-hold-checkout.ts
Free limited ticket claimdocs/developer/examples/free-ticket-claim.ts

Errors and retries

Failed requests throw AtmApiError with a stable code, HTTP status and parsed body. Contract checks throw AtmCheckoutContractError: before sending an input that breaks the contract, and on a reply or stored attempt that does. Retry network failures, 401, 429 and 503 with the same attempt ID. A missing reply is never proof of non-payment.

ts
import { AtmApiError } from "@atmosphere-money/app-node";

try {
  await attempts.recover("order_123_attempt_1");
} catch (error) {
  if (error instanceof AtmApiError && error.code === "RecipientNotPayable") {
    showSetupRequiredState();
  } else if (!(error instanceof AtmApiError) || [401, 429, 503].includes(error.status)) {
    // Network failure or retryable status: try again later with the same
    // attempt ID. recover replays the original request and key.
  } else {
    throw error; // keep the attempt for support; never replace it automatically
  }
}

Every native error code and its expected recovery is on Checkout.

API surface

createAtmCheckoutAttemptsDurable capture, recovery and reconciliation of native test checkouts.
createAtmFileStoreA durable compare-and-swap store for one server on a private persistent volume.
AtmDurableStoreThe store interface to implement with compare-and-swap in your shared database.
createAtmAppClientA backend client for createCheckout, getCheckoutStatus, profiles, configuration and Tickets calls.
ATM_XRPC_METHODSMethod constants, so app code avoids scattered NSID strings.
constructAtmWebhookEventVerify an HTTP webhook signature and parse the event envelope.
constructTypedAtmWebhookEventVerify a webhook and narrow data for a known event type.
createNodeWebhookHandlerA Request/Response webhook handler for Node-compatible runtimes.
createNextWebhookRouteAlias for Next route handlers and other Web Request runtimes.
createExpressWebhookHandlerAn Express-style webhook handler without an Express dependency.
createHonoWebhookHandlerA Hono route handler around the same signed webhook verification.
createCloudflareWorkerWebhookHandlerA Workers fetch handler around the same signed webhook verification.
constructAtmXrpcReceiverEventVerify canonical XRPC receiver service-auth and parse the same envelope.
constructTypedAtmXrpcReceiverEventVerify an XRPC receiver event and narrow data for a known event type.
verifyServiceAuthRequestVerify a service-auth bearer request before custom XRPC receiver routing.
createTicketHoldBody, createFreeTicketClaimBodyValidate ticket hold and free claim request bodies before calling Tickets methods.
signAtmWebhookPayloadTest helper for local webhook signature fixtures.
AtmApiError, AtmCheckoutContractErrorA structured request failure, and a contract refusal for an input, reply or stored attempt.

Payments

createCheckout and getCheckoutStatus, plus createAtmCheckoutAttempts. The SDK still exports the legacy initiatePayment and getPaymentStatus; new integrations must not use them.

Profiles

getProfile reads ATM profile data from the AppView.

Tickets

Ticket types, capacity, availability, holds, release, claims, lists, verify and check-in.

Events

Canonical XRPC receiver and HTTP webhook constructors share one envelope shape.

Go live with the SDK

  • Keep service-auth minting, attempt storage and webhook secrets on your backend.
  • Capture every attempt before contacting ATM, and retry only with its original request and key.
  • Reconcile from a backend worker and grant purchases only on completed plus fulfil.
  • Verify notification authentication, then queue reconciliation; never grant from the event alone.
  • Store delivery IDs, payment IDs and effect keys before sending downloads, emails or app changes.
  • Test restart recovery, duplicate deliveries, redrive and unavailable states.
  • Live access is a separate review. Never reuse test secrets or receivers in live.

Browser packages

Browser embeds belong in separate packages. ATM checkout embeds can become an @atmosphere-money/checkout-embed wrapper around an ATM-hosted iframe, with hosted checkout as the fallback.