merce.STACK
merce.STACK
Skip to content
PricingWhat's new
Log inGet started
{}Developers
GuidesAPI referenceChangelogGet API keys →
  • Get started

    • Quickstart
    • Keys & authentication
  • Storefront

    • Products & catalog
    • Carts
    • Checkout & payment
    • Customer accounts
    • Digital products
    • Without a build step
    • Bookings
    • Courses
    • Drop-in components
  • Server API

    • Server API
    • Customers
    • Payment links & transactions
    • Balance & payouts
    • Classes & students
    • Node SDK
  • Email API

    • Email API
    • Sending email
    • Delivery events
  • Events & errors

    • Webhooks
    • Errors
  • Reference

    • API reference
    • Changelog

Server API

Node SDK

`@mercestack/node` — a typed client for the server API.

Shell
pnpm add @mercestack/node
TypeScript
import { Mercestack } from "@mercestack/node";

const mercestack = new Mercestack(process.env.MERCESTACK_SECRET_KEY!);

const link = await mercestack.paymentLinks.create(
  { title: "Invoice 88", amount: "150000" },
  { idempotencyKey: "invoice-88" },
);
  • —Throws on a publishable key before sending anything.
  • —Retries network errors, 429 and 5xx — but a create only when you gave it an idempotencyKey, so a retry can't charge twice.
  • —.all() on customers and transactions walks every page for you.
  • —Errors are MercestackError with status, code, message and requestId.

Webhooks

TypeScript
app.post("/mercestack", express.raw({ type: "application/json" }), (req, res) => {
  const event = mercestack.webhooks.constructEvent(
    req.body,                                  // the raw bytes
    req.header("Mercestack-Signature"),
    process.env.MERCESTACK_WEBHOOK_SECRET!,
  );
  if (event.type === "payment_link.paid") fulfil(event.data);
  res.sendStatus(200);
});

Methods

TypeScript
mercestack.customers.list(params)      .retrieve(id)   .create(input)   .update(id, input)   .all()
mercestack.paymentLinks.list(params)   .retrieve(id)   .create(input)   .deactivate(id)
mercestack.transactions.list(params)   .retrieve(idOrReference)         .all()
mercestack.balance.retrieve()
mercestack.payouts.list()
mercestack.classrooms.list()           .retrieve(id)
mercestack.classrooms.enrollments.list(classId)       .create(classId, input)
mercestack.products.list()             .retrieve(id)
mercestack.orders.list()               .retrieve(id)
mercestack.webhooks.constructEvent(rawBody, signature, secret)

Email API

The same package has a client for the Email API, which takes an Email API key (msk_live_…) and talks to emailapi.mercestack.com. See Email API for the endpoints.

TypeScript
import { MercestackEmail } from "@mercestack/node";

const email = new MercestackEmail(process.env.MERCESTACK_EMAIL_KEY!);

email.emails.send(input, { idempotencyKey })   .batch(messages)   .get(id)   .cancel(id)
email.templates.list()   .get(aliasOrId)   .create(input)   .update(aliasOrId, input)   .remove(aliasOrId)
← PreviousClasses & studentsNext →Email API

On this page

  • Webhooks
  • Methods
  • Email API
Create a workspaceTalk to usPricing

One workspace for everything your business runs on — your team, customers, store, marketing and payouts in one place.

Get started

Product

  • All products
  • Pricing
  • What's new
  • Security

Resources

  • Documentation
  • Guides
  • Use cases
  • Blog
  • Get support

Company

  • About
  • Careers
  • Contact us
  • Talk to the team

Legal

  • Privacy
  • Terms
  • Cookie policy
  • GDPR
  • Report a vulnerability

© 2026 Mercestack. All rights reserved.

Mercestack StructureOS

mercestack